mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-30 18:15:01 +01:00
Don't convert to f64 until we know that's the type that we actually want. Also reimplement the conversion from RealId to FloatId to perform an exact conversion with a real check for overflow, rather than performing an approximate conversion via the host `double` type. Unfortunately, LLVM doesn't expose its integer mantissa and exponent to APFloat conversion, so we convert the RealId back to a string for now. The LLVM conversion also detects overflow only if the literal would round to having an out-of-range exponent, not if the literal is outside the range of values of the type as the Carbon design expects. It's not clear to me which rule we actually want here, so for simplicitly I'm using the LLVM rule for now. In preparation for adding other floating-point types beyond f64.