Re: .98 cents instead of .99



On 30 Jan 2006 05:42:42 -0800, "Googmeister" <googmeister@xxxxxxxxx>
wrote, quoted or indirectly quoted someone who said :

>
>Try (int) (Math.round(100 * (amountPaid - totalCost)))
>
>Or better use, store the amount as an int/long in pennies
>or use BigDecimal to avoid floating point precision issues.
for more discussion of the problem of currency calculation see
http://mindprod.com/jgloss/currency.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
.



Relevant Pages

  • Re: Decimal Data Type losing scale?
    ... > defined at precision of 15 and scale of 2. ... > When I use a T-Sql update query, I'm sending a value "with pennies", ... I DO SEE the pennies. ...
    (microsoft.public.sqlserver.programming)
  • Re: Packed decimal arithmetic in C
    ... >> of, say, Fortran, then you can approximate the value of a decimal, but in ... > has 33 decimal digits of precision, it gives you even more room than ... That is exactly what I had in mind. ... I used D floating and pennies. ...
    (comp.os.vms)
  • Re: Packed decimal arithmetic in C
    ... >> Not to speak directly for John, but I often tell people that they can ... >> has 33 decimal digits of precision, it gives you even more room than ... pennies doesn't need to be expressed precisely. ...
    (comp.os.vms)