Prev: Shell Sort
Next: matrix package with Ada
From: Jacob Sparre Andersen on 13 Jul 2010 07:26 Adam Beneschan wrote: > That will probably work for my purpose; but in general, it's easy to > define a fixed-point number with a 'Small of 2**(-N) that has more > bits to the right of the binary point than are available in the > mantissa part of the floating-point. If that's the case, this > approach will fail on certain values (probably M - (K * T'Small) for > integer M and suitably small integer K). Since this situation lends > itself to really efficient code (basically just a bit shift), it's > kind of a shame that the language doesn't give you a good way to do > this. Isn't it possible to write a truncation function, which uses bit shift when it is appropriate? If the 'Small is statically known, there is a fair chance that the compiler will remove the unused branch at compile-time. Jacob -- "If we weren't at least occasionally surprised by the results, we might as well save ourselves the trouble of measuring :)" |