In reply to dave_59:
In reply to prashantg:
The problem is the fractional part of d is not exactly 0.5. Display using “%.17f”.
There is also rounding in the conversion from binary to decimal. Use $realtobits to see the internal binary representation.
Thanks, Dave for the insight.
Some additional queries:
- Decimal place till which a single expression is calculated?
- Is this behaviour consistent across simulators?
- Does type casting from real to int i.e. int’ use $realtobits?