declaring variables...

  • Thread starter Thread starter noobee
  • Start date Start date
N

noobee

hi all...

I have the following figures in my program

345.234
789.123
-345.892
-123.456

what do I declare them as?? long? integer? short? decimal?

Gary
 
Because you have decimals in all those numbers, none of the integer types
(short, integer, long) would preserve the decimal, so "decimal" is the way
to go.
 
* "noobee said:
I have the following figures in my program

345.234
789.123
-345.892
-123.456

what do I declare them as?? long? integer? short? decimal?

It depends on what is important when doing calculations with the
number. 'Decimal' is good if you want to avoid floating point errors,
if the result doesn't need to be very precise, then you can use a
Double... It's hard to give a general advice.
 
Back
Top