Re: Adding int to a float
- From: Arne Vajhøj <arne@xxxxxxxxxx>
- Date: Fri, 18 Sep 2009 20:19:14 -0400
Martin Gregorie wrote:
If you're doing financial calculations you should always use integer arithmetic because this avoids nasty surprises due to the inability of floating point to accurately represent all possible values. This also applies to currency conversion. All FX dealing institutions and markets specify precisely how to handle the conversion: using floating point doesn't figure in their rules.
All reputable financial software uses integers with monetary values held in the smallest legal unit in the currency (cents in $US and Euros, pence in the UK).
I think integers needs to be interpreted broad here.
If it covers binary integers and BCD with either application
managed decimal or encapsulated in the data type decimal, then
I agree.
But money is definitely not always store in datatypes equivalent
to Java int.
Arne
.
- Follow-Ups:
- Re: Adding int to a float
- From: Martin Gregorie
- Re: Adding int to a float
- References:
- Adding int to a float
- From: Frank Cisco
- Re: Adding int to a float
- From: Frank Cisco
- Re: Adding int to a float
- From: neuneudr
- Re: Adding int to a float
- From: markspace
- Re: Adding int to a float
- From: Martin Gregorie
- Adding int to a float
- Prev by Date: Re: Adding int to a float
- Next by Date: Re: IDE plugin to help null handling
- Previous by thread: Re: Adding int to a float
- Next by thread: Re: Adding int to a float
- Index(es):
Relevant Pages
|