Re: 34.123*89 = 3036.95 (3036.947)
- To: mathgroup at smc.vnet.net
- Subject: [mg47958] Re: 34.123*89 = 3036.95 (3036.947)
- From: ancow65 at yahoo.com (AC)
- Date: Sun, 2 May 2004 04:50:58 -0400 (EDT)
- References: <c6s538$pkf$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
thomas-k-schulz at t-online.de (Thomas Schulz) wrote in message news:<c6s538$pkf$1 at smc.vnet.net>... > I am a NewBe - and i dont understand the Result. > Mathematica says that 34.123*89 = 3036.94699999997 but its 3036.947... > How can i change this? > > i use a IBook (G4) with Mac OS X. > THX > Thomas Thomas, In my opinion, which definitely is not shared by mathematica developers, you pointed to a design problem. By default, Mathematica treats decimals as approximate numbers no matter what you might think. One way to get what you want is to use rationals and take the numerical value afterwards. (34123/1000)*89 // N You can also use 'elegant' tricks like the following one. ToExpression[StringTake[ToString[34.123*89], 7]] => 3036.95 Because you said that you a beginner, I am warning you. Don't play with trailing zeros. ToExpression[StringTake[ToString[34.12300000000000*89], 7]] => 3036.95 ToExpression[StringTake[ToString[34.1230000000000000*89], 7]] => 3036.94 I am being sarcastic here. I refer you to a current thread on mathgroup 'Re: bug in IntegerPart ?' that discusses the core of your problem. There were also number of tasty discussions on the subject in past on math group and sci.math.symbolic. Cheers, AC