# Behaviour of RealDigits expected or wrong?

Is this behavior expected or a bug?

RealDigits[10304.390456]

{{1, 0, 3, 0, 4, 3, 9, 0, 4, 5, 5, 9, 9, 9, 9, 9}, 5}

when I expected

{{1, 0, 3, 0, 4, 3, 9, 0, 4, 5, 6, 0, 0, 0, 0, 0}, 5}

17 significant figures doesn’t make a difference as I would have expected considering that \$MachinePrecision->15.9546.

RealDigits[10304.390456000000]

{{1, 0, 3, 0, 4, 3, 9, 0, 4, 5, 5, 9, 9, 9, 9, 9}, 5}

This is far from a the limit of machine-precision number representation.

RealDigits[10304.390456000000 + 10^3 \$MachineEpsilon]

{{1, 0, 3, 0, 4, 3, 9, 0, 4, 5, 5, 9, 9, 9, 9, 9}, 5}

18 significant figures does make a difference

RealDigits[10304.3904560000000]

{{1, 0, 3, 0, 4, 3, 9, 0, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0}, 5}

=================

You implicitly changed a decimal fraction to binary, and then explicitly changed it back to decimal.
– John Doty
Oct 13 ’15 at 13:55

@JohnDoty wholdn’t that give me an error of only \$MachineEpsilon i.e around 2.22045*10^-16? This is three orders of magnitude bigger!
– rhermans
Oct 13 ’15 at 13:57

4

Expect errors of around x*\$MachineEpsilon, where x is the number in question.
– John Doty
Oct 13 ’15 at 14:01

– rhermans
Oct 13 ’15 at 14:02

1

the change in the last case is because you supplied enough digits to force an extended precision representation. ByteCount[10304.390456000000]->16 … ByteCount[10304.3904560000000]-> 80
– george2079
Oct 13 ’15 at 18:18

=================