Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Re: Re: Re: Filthy Floats

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


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 19: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
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-25 03:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found