4 ms·
>> But that means you really need five variants of the sin function and you need to dynamically dispatch between them based on the current rounding mode Just d
by phkahler 12y ago
>> But that means you really need five variants of the sin function and you need to dynamically dispatch between them based on the current rounding mode
Just define a rounding behavior for the language and implement it that way. Don't claim full 754 support, just specify the strategy used by the language. A sin function should behave according to the design of that function and should be able to ignore any previous state of the FP hardware. I have not seen a language that directly supports setting the rounding modes, so any language libraries can do what they like - you don't need to preserve or worry about something you don't offer the option to modify.
- gre 12y agoCheck out my other comment below. Factor has with-rounding-mode and you can nest these modes. Example: +round-up+ [ 1.0 3.0 /f double>bits .h +round-zero+ [ 1.0 3.0 /f double>bits .h ] with-rounding-mode ] with-rounding-mode ! output ! 3fd5555555555556 ! 3fd5555555555555
- andrioni 12y agoJulia also supports this: with_rounding(Float64, RoundUp) do println(bits(1.0 / 3.0)) with_rounding(Float64, RoundToZero) do println(bits(1.0 / 3.0)) end end 0011111111010101010101010101010101010101010101010101010101010110 0011111111010101010101010101010101010101010101010101010101010101