Re: Beware of adding 0.0
- To: mathgroup at smc.vnet.net
- Subject: [mg50232] Re: Beware of adding 0.0
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Sun, 22 Aug 2004 00:19:41 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On 8/21/04 at 3:04 AM, gruszkiewicz at ornl.gov (Mirek Gruszkiewicz) wrote: >This is normal: >o=SetPrecision[1/9, 25] >oo=SetPrecision[1./9, 25] >0.1111111111111111111111111 >0.1111111111111111049432054 >Here is the magic: >ox = SetPrecision[o + 0.0, 25] >ooxx = SetPrecision[oo + 0.0, 25] >0.1111111111111111049432054 >0.1111111111111111049432054 If you consider the first example as "normal" why do you see the second as "magic"? SetPrecision[1./9, 25] is exactly equivalent to SetPrecision[SetPrecision[1/9, MachinePrecision], 25] So not surprisingly SetPrecision[1/9 , 25] doesn't give the same result Now, 0.0 is a MachinePrecision number. So, you should expect adding 0.0 to any number with higher precision should result in a MachinePrecision number That is: SetPrecision[o + 0.0, 25] is equivalent to SetPrecision[SetPrecision[o, MachinePrecision], 25] which is equivalent to SetPrecision[SetPrecision[1/9, MachinePrecision], 25] And SetPrecision[oo + 0.0, 25] is equivalent to SetPrecision[SetPrecision[oo, MachinePrecision], 25] which has already been shown to be equivalent to SetPrecision[SetPrecision[1/9, MachinePrecision], 25] that is the same result is obtained for both ox and ooxx -- To reply via email subtract one hundred and four