I actually have a solution but it's a bit of a kludge.
My solution is to use regular expression and just drop everything prior to the
decimal position like so:
[temp=. ": 105.1
105.1
". '0', temp }.~ {.,'\.' rxmatch temp
0.1
I was hoping that there is another (non-kludge) way.
r/Alex
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Alex Rufon
Sent: Wednesday, April 29, 2009 7:47 PM
To: Programming forum
Subject: Re: [Jprogramming] Getting the decimal values
Unfortunately, the client wants it in the original value (0.1) and not the
expanded value (0.0999999999999996). :(
-----Original Message-----
From: [email protected]
[mailto:[email protected]] 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 <[email protected]>:
> Fra: Alex Rufon <[email protected]>
> Emne: [Jprogramming] Getting the decimal values
> Til: "Programming forum" <[email protected]>
> 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm