[Jprogramming] Getting the decimal values
Alex Rufon
alex_rufon at ist-systems.com
Wed Apr 29 19:46:37 HKT 2009
Unfortunately, the client wants it in the original value (0.1) and not the expanded value (0.0999999999999996). :(
-----Original Message-----
From: programming-bounces at jsoftware.com [mailto:programming-bounces at jsoftware.com] On Behalf Of Bo Jacoby
Sent: Wednesday, April 29, 2009 7:17 PM
To: Programming forum
Subject: Re: [Jprogramming] Getting the decimal values
0.0999999999999996 is probably a correct floating point representation of 0..1.
Coding a hook is shorter, however:
decimal =: -<.
--- Den ons 29/4/09 skrev Alex Rufon <alex_rufon at ist-systems.com>:
> Fra: Alex Rufon <alex_rufon at ist-systems.com>
> Emne: [Jprogramming] Getting the decimal values
> Til: "Programming forum" <programming at jsoftware..com>
> Dato: onsdag 29. april 2009 13.28
> Hello.
>
> I made the following verb to get the decimal value of a
> floating point number:
>
> decimal=: 3 : 0
> y - <. y
> )
>
> The problem is this:
> decimal 5.1
> 0.0999999999999996
>
> But using a decimal value greater than 1 would return the
> correct result:
> decimal 5.2
> 0.2
> decimal 5.11
> 0.11
>
> Any idea what I should do next?
>
> Thanks.
>
> r/Alex
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
________________________________________________________
Audi, Fiat, Peugeot, Skoda, Porsche, Toyota, Ford - Kelkoo har brugte biler til en hver smag! Klik her for at sammenligne priser.(http://dk.yahoo.com/r/pat/mmb)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list