# Showing what happens with a number beyond machineprecision

I want to play around a bit in Mathematica to understand how floating-point precision, rounding and truncation actually works. I understand that Machineprecision is $2^{-52}$.

First of all I would like to create a binarynumber and show that it is correct until the machinecorrection and after that it starts to be 'random'. But how do I do this? For example:

BaseForm[1/3 // N, 2]

Generates: $0.010101010101010101011_2$

1. Why are there $21$ digits after the dot?
2. Why not $52$? How can I get $52$?
3. How can I show this number in the form the computer stores it? That is, with an exponent and a mantissa?
4. How to show what happens to a number beyond machineprecision?

This is all quite new to me, so any help is appreciated. I am sorry for the lack of knowledge.

Maybe in other words, I firstly try to understand why this code:

BaseForm[1 + $MachineEpsilon, 2] Doesn't generate a binary number with$52$digits. • (1) BaseForm is being applied to the "standard" form, which truncates to 6 decimal digits. (2) FIrst apply InputForm: In[117]:= BaseForm[InputForm[N[1/3]], 2] Out[117]//BaseForm= \!$$TagBox[ InterpretationBox[ StyleBox["2^^0.010101010101010101010101010101010101010101010101010101", ShowStringCharacters->True, NumberMarks->True], InputForm[0.3333333333333333], AutoDelete->True, Editable->True], BaseForm[#, 2]& ]$$ (3) Check RealDigits (4) It falls off the end of the Earth. – Daniel Lichtblau Dec 4 '16 at 16:11 • @DanielLichtblau, Hi; I did not know that and was wondering too. It is worth being an answer so it can be upvoted. +1 – bobbym Dec 4 '16 at 16:19 • @DanielLichtblau What do you mean by "It falls off the end of the Earth"? Is the "rest" simply discarded? Or does some kind of rounding take place? If so, what kind of rounding? – GambitSquared Dec 4 '16 at 16:57 • Just kidding about that item (4). I haven't tried but possibly what you'd want is to use N[...,prec] with prec set to something larger than$MachinePrecision. – Daniel Lichtblau Dec 4 '16 at 17:04

(1) BaseForm is being applied to the "standard" form, which truncates to 6 decimal digits. (2) FIrst apply InputForm: In[117]:= BaseForm[InputForm[N[1/3]], 2] Out[117]//BaseForm= \!$$TagBox[ InterpretationBox[ StyleBox["2^^0.010101010101010101010101010101010101010101010101010101", ShowStringCharacters->True, NumberMarks->True], InputForm[0.3333333333333333], AutoDelete->True, Editable->True], BaseForm[#, 2]& ]$$ (3) Check RealDigits (4) It falls off the end of the Earth. – Daniel Lichtblau Dec 4 '16 at 16:11