Am Mon, 24 Mar 2014 09:51:02 +0000 schrieb "Don" <x...@nospam.com>:
> It is indeed a common floating-point bug. > > I came up with a solution for this a couple of years ago, never > got around to doing a pull request, but it's on the newsgroup > somewhere. It's a little extension to the range propagation > implementation. You add a boolean flag to the range, which > indicates 'a fractional part has been discarded'. This flag gets > set whenever you perform an integer division (or integer > exponentiation with a negative power), and is cleared whenever > there is a cast or a bitwise operation. > > Then, disallow implicit casting from integer to floating point > whenever the fractional bit is set. Catches all these kinds of > bugs, doesn't require any changes to the language. Sounds awesome. Could that also be applied to this as well?: mask = 1 << bitNum; -- Marco