# What happens at the end of MachinePrecision? Is the remainder discarded or rounded?

What happens at the end of MachinePrecision? Is the remainder discarded or rounded?

This code suggests it is discarded; is that conclusion correct? Why is it not rounded?

BaseForm[InputForm[1 + $MachineEpsilon], 2] BaseForm[InputForm[1 + 1/2*$MachineEpsilon + 1/4*$MachineEpsilon], 2]  • @nikie But this seems to be rounded: BaseForm[InputForm[1 + 0.1], 2] – GambitSquared Dec 5 '16 at 9:33 • Well, that's my question, whether the remainder is discarded or rounded (possibly up) – GambitSquared Dec 5 '16 at 9:37 ## 1 Answer It looks like it's rounded to nearest, with ties to 0, but since this rounding is done by the CPU, it might even be system dependent. On my system I get: BaseForm[InputForm[1.0 +$MachineEpsilon*0.5], 2]


2^^1.

BaseForm[InputForm[1.0 + $MachineEpsilon*0.500000001], 2]  2^^1.0000000000000000000000000000000000000000000000000001 Note also that floating point addition is not associative, so this: BaseForm[InputForm[(1 + 1/2*$MachineEpsilon) + 1/4*$MachineEpsilon], 2]  2^^1. is not the same as this: BaseForm[InputForm[1 + (1/2*$MachineEpsilon + 1/4*\$MachineEpsilon)],
2]


2^^1.0000000000000000000000000000000000000000000000000001

• I think the rules are set firmly by IEEE 754. – The Vee Dec 5 '16 at 15:01
• I'm seeing rounding to nearest with round ties to even, which is in accordance with one of the options in IEEE 754 (2008). My experience on this site is that numerics have been consistent with the results on my machine so that it is unlikely that different systems use different rounding attributes. @TheVee: An implementation of IEE 754 is supposed to support all rounding attributes, including the three other directed rounding attributes, but in practice, it seems systems do not always provide a way for users to select the mode. – Michael E2 Dec 5 '16 at 23:50