Re: sorry .09 instead of .08
- From: zero <zero@xxxxxxx>
- Date: Mon, 30 Jan 2006 19:22:30 GMT
Thomas Hawtin <usenet@xxxxxxxxxxxxxxxxx> wrote in
news:43dd574f$0$1460$ed2619ec@xxxxxxxxxxxxxxxxxxxxxxxxxx:
> zero wrote:
>>
>> BigDecimal will be slower though. If the values are all currency
>> values, with only 2 numbers after the decimal point, ints are a good
>> choice.
>
> They are slower. However, is it going to make your program noticeably
> slower. Almost certainly not. Better to keep it safe than prematurely
> optimise.
>
> Using ints is full of traps. No good for a billionaire companies,
> although longs should do for storage. Operations such as
> multiplication become tricky. Without treating it as a type in its own
> right, you can easily get into trouble.
>
> Tom Hawtin
BigDecimal has its own problems, beside the speed. If you initialize a
BigDecimal with a double constant, you're in the same boat as using a
normal double when it comes to rounding errors.
I would suggest int or long for financial calculations, and BigDecimal if
you're dealing with more numbers after the decimal point.
.
- Follow-Ups:
- Re: sorry .09 instead of .08
- From: Thomas Hawtin
- Re: sorry .09 instead of .08
- References:
- sorry .09 instead of .08
- From: joshdalrymple2000
- Re: sorry .09 instead of .08
- From: James Westby
- Re: sorry .09 instead of .08
- From: Thomas Hawtin
- Re: sorry .09 instead of .08
- From: zero
- Re: sorry .09 instead of .08
- From: Thomas Hawtin
- sorry .09 instead of .08
- Prev by Date: Re: sorry .09 instead of .08
- Next by Date: Re: sorry .09 instead of .08
- Previous by thread: Re: sorry .09 instead of .08
- Next by thread: Re: sorry .09 instead of .08
- Index(es):
Relevant Pages
|