Beefy Boxes and Bandwidth Generously Provided by pair Networks kudra
Keep It Simple, Stupid
 
PerlMonks  

Re: Re: Re: Re: Filthy Floats

by John M. Dlugosz (Monsignor)
on Jul 16, 2001 at 21:41 UTC ( [id://97188]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: Re: Re: Filthy Floats
in thread Filthy Floats

Perl 6 will have "big rats" that will represent 98/100 exactly. For now, you can use ints and do it yourself. Are you doing arithmetic on the value you fetch? I assume so, or it would not be converted from a string to a number. So, fetch the value, and use a regex to remove the decimal point and note how many digits were to the right of it originally. Now value X becomes (Y*Z) where Y is your integer and Z is the implicit power of ten. Do your math with Y, and also see what becomes of Z in the formulas but keep it implicit. When displaying stick the decimal in the string based on Z, but don't divide.

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Filthy Floats
by THuG (Beadle) on Jul 17, 2001 at 15:18 UTC

    Well, I'm getting the number from the DB, and then multiplying it against another number, modifying the other number. And then I'm displaying the number.

    It was treated as a number at some point in its history, even though I'm displaying it as a string and not really doing any math to it when I display it.

    Anyway, its all been resolved. At some point it is being converted to a single and Perl assumes those digits are significant. If I could pull the double from the DB and use it as a double I would be happy, but even if it is set as a double, it still becomes a single.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://97188]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.