You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BigInteger conversions to float, Half, and BFloat16 risk double rounding #125837
The explicit conversion operators from BigInteger to float, Half, and BFloat16 all convert via double as an intermediate step, which risks double rounding bugs:
Round the arbitrary-precision integer to double (53-bit mantissa)
Round the double to the target type (24-bit for float, 11-bit for Half, 8-bit for BFloat16)
The composition of two correctly-rounded operations is not guaranteed to produce a correctly-rounded result. When the BigInteger value falls exactly at a double-rounding boundary, the intermediate double representation can cause the final result to be off by 1 ULP in the target type.
Expected Fix
Each of these conversions should handle the rounding directly from BigInteger to the target floating-point type, without an intermediate double step. This would ensure correctly-rounded results for all inputs.
Activity
dotnet-policy-service commentedon Mar 20, 2026
Tagging subscribers to this area: @dotnet/area-system-numerics
See info in area-owners.md if you want to be subscribed.
huoyaoyuan commentedon Mar 21, 2026
#112474
Fix rounding of BigInteger conversions to floating-point types (dotne…
Fix rounding of BigInteger conversions to floating-point types (#130565)