Int to Real
D = A + B x 10 ^ (-C)
Real to Int
A = XXXXXX.YYYYYY
C = XXXXXX
D = Round 0.YYYYYY to B decimal places, then multiply by 10 ^ B
At least I think this is what it’s supposed to do – it seems to have some issues:
- Rounding close to 0.5 can be somewhat unpredictable. e.g. A = 5.246, B = 1 will give D=3, not D=2 as it should.
- Note that the Integer part is always simply truncated – don’t expect this function to Round correctly – e.g. A = 12.99, B = 1 will give C=12 and D=10, instead of C=13, D=0 as you might expect!