Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Decimal numbers calculations done inconsistently: Odd behavior!

by Krambambuli (Curate)
on Mar 20, 2015 at 09:35 UTC ( #1120720=note: print w/replies, xml ) Need Help??


in reply to Decimal numbers calculations done inconsistently: Odd behavior!

Since your decimals seem to always have exactly two fractional digits, it might suffice to "translate" everything into an 100x integer space. So you might write
($open, $high, $low, $close) = map { s/\.//; $_; } @arr[3, 4, 5, 6];
and forget about the *100 multipliers in the following code.

Of course, you'll have to add back the 'decimal dots' when outputting the results.

---
Krambambuli
  • Comment on Re: Decimal numbers calculations done inconsistently: Odd behavior!
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1120720]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2019-11-21 06:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (103 votes). Check out past polls.

    Notices?