Thanks to everyone who suggested solutions to the decimal code. I really like 
the one by Ric Sherlock which goes:
   1|5.01
0.0099999999999997868
   1|5.1
0.099999999999999645
   1|5.2
0.20000000000000018

Hahahah. I still have that print precision thingy on my laptop though but its 
fixed now on the client so I'm happy. :)

r/Alex

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Björn Helgason
Sent: Thursday, April 30, 2009 4:41 AM
To: Programming forum
Subject: Re: [Jprogramming] Getting the decimal values

/home/bjorn/j602/help/dictionary/d230.htm

     res=: [email protected]"0
      agenda=: ([ = 0:) +. (<. = >.)@S
         S=: ] % [ + [ = 0:
      f=: ] - [ * <....@s
      g=: ] * [ = 0:
   1 res 2.03 5.1 6.3 3j1.1 5.11 1.67 0.003
0.03 0.1 0.3 0j0.1 0.11 0.67 0.003



2009/4/29 Alex Rufon <[email protected]>

> 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
>



-- 
Björn Helgason, Verkfræðingur
Fugl&Fiskur ehf,
Þerneyjarsundi 23, Hraunborgum
Po Box 127,801 Selfoss ,
t-póst: [email protected]
gsm: +3546985532
Landslags og skrúðgarðagerð, gröfuþjónusta
http://groups.google.com/group/J-Programming


Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans

góður kennari getur stigið á tær án þess að glansinn fari af skónum
         /|_      .-----------------------------------.
        ,'  .\  /  | Með léttri lund verður        |
    ,--'    _,'   | Dagurinn í dag                     |
   /       /       | Enn betri en gærdagurinn  |
  (   -.  |        `-----------------------------------'
  |     ) |         (\_ _/)
 (`-.  '--.)       (='.'=)   ♖♘♗♕♔♙
  `. )----'        (")_(") ☃☠
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to