       Re: Is there a simple way to transform 1.1 to 11/10?

• To: mathgroup at smc.vnet.net
• Subject: [mg92994] Re: Is there a simple way to transform 1.1 to 11/10?
• From: Szabolcs Horvat <szhorvat at gmail.com>
• Date: Wed, 22 Oct 2008 05:39:01 -0400 (EDT)
• Organization: University of Bergen
• References: <gdkajv\$4r2\$1@smc.vnet.net>

```Alain Cochard wrote:
> The obvious
>
>     In:= x=1.1`Infinity
>
> is not syntactically correct.
>
> I understand that SetPrecision[1.1,Infinity] does not work either:
>
>     In:= SetPrecision[1.1,Infinity]
>
>             2476979795053773
>     Out= ----------------
>             2251799813685248
>
>     In:= N[%,20]
>
>     Out= 1.1000000000000000888
>
> I searched the newsgroup and thought I had the solution with Rationalize:
>
>     In:= Rationalize[1.1,0]
>
>             11
>     Out= --
>             10
>
> But
>
>     In:= Rationalize[1.000000001,0]
>
>             999999918
>     Out= ---------
>             999999917
>
>     In:= N[%,20]
>
>     Out= 1.0000000010000000830
>
> So any simple way?
>

Hello Alain,

Rationalize is the way to go.  Floating point numbers are usually stored
in a binary (not decimal) representation on computers.  1.000000001 is
not exactly representable in binary (in the same way as 1/3 =
0.3333333... is not exactly representable in decimal).  Note that in
digits), and then convert back to a number with 20 digits of precision.

In:= Rationalize[1.000000001`20, 0]
Out= 1000000001/1000000000

In:= N[%, 20]
Out= 1.0000000010000000000

Another example:

In:= Rationalize[N[Sqrt, 30], 0]
Out= 1023286908188737/723573111879672

In:= N[%, 30]
Out= 1.41421356237309504880168872421

In:= % - Sqrt
Out= 0.*10^-30

```

• Prev by Date: Re: partial Dividers?
• Next by Date: Re: Is there a simple way to transform 1.1 to 11/10?
• Previous by thread: Re: Is there a simple way to transform 1.1 to 11/10?
• Next by thread: Re: Is there a simple way to transform 1.1 to 11/10?