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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top