# Revision history [back]

To get the binary representation just add a .str(base=2) to the approximated value.

 sage:  a = pi + sqrt(2)
sage:  a.n(digits=60).str(base=2)
'100.1000111001001001010100001111000010'


To get the binary representation just add a .str(base=2) to the approximated value.

 sage:  a = pi + sqrt(2)
sage:  a.n(digits=60).str(base=2)
'100.1000111001001001010100001111000010'


For the other direction the method RR is useful. Given as first Argument the string and as second the base.

 sage:  s= a.n(digits=60).str(base=2)
sage:  RR(s,2)
4.55580621596289


To get the binary representation just add a .str(base=2) to the approximated value.

 sage:  a = pi + sqrt(2)
sage:  a.n(digits=60).str(base=2)
'100.1000111001001001010100001111000010'


For the other direction the method RR is useful. Given as first Argument argument the string and as second the base.

 sage:  s= a.n(digits=60).str(base=2)
sage:  RR(s,2)
4.55580621596289


To get the binary representation just add a .str(base=2) to the approximated value.

 sage:  a = pi + sqrt(2)
sage:  a.n(digits=60).str(base=2)
a.n(digits=10).str(base=2)
'100.1000111001001001010100001111000010'


For the other direction the method RR is useful. Given as first argument the string and as second the base.

 sage:  s= a.n(digits=60).str(base=2)
sage:  RR(s,2)
4.55580621596289