Best Unit of Measurement for Conversion
I'm creating a class with that does a lot of conversion(miles to kilometers, feet to yards, meters to miles).
What is the type of number to use?:
1. int
2. double
3. f oat
4. long
and obvioulsy not an int.
I'm creating a class with that does a lot of conversion(miles to kilometers, feet to yards, meters to miles).
What is the type of number to use?:
1. int
2. double
3. f oat
4. long
and obvioulsy not an int.
There's almost never any point in using float unless you were in a very limited memory environment.
Int and long don't make sense, since these are non-integer quantities.
You *could* use BigDecimal, but this isn't money, so the fixed decimal precision is probably unnecessary.
I'd go with double.