Number

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

What should be the data type for holding numbers with 2 decimal places
(2.32, 4.23, 1.23, ...)?

Thanks,
Miguel
 
Hello,

What should be the data type for holding numbers with 2 decimal places
(2.32, 4.23, 1.23, ...)?

Thanks,
Miguel

Personally I would use decimal over float
 
precision.

a float is in 2 complement, not decimal, so 1/10, is not really .01, and
can cause errors in summations.

decimal is really done as an integer value with an implied decimal
point, so .01 is really .01


-- bruce (sqlwork.com)
 
precision.

a float is in 2 complement, not decimal, so 1/10, is not really .01, and
can cause errors in summations.

decimal is really done as an integer value with an implied decimal point,
so .01 is really .01

Sure, but the OP is looking for the most efficient way of storing numbers
with two decimal places... A float is fine for that, and will require only
32 bits as opposed to the 128 bits required by a decimal...
 
shapper said:
Hello,

What should be the data type for holding numbers with 2 decimal places
(2.32, 4.23, 1.23, ...)?

Thanks,
Miguel

That depends on what you are going to use them for.

Double is the most common data type for floating point numbers, and
generally gives the best performance.

If you have a lot of numbers, you can use Single. As it's smaller you
get better performance, as there is less data to move around.

If you need absolute precision, you can use Decimal. It's larger, but it
doesn't approximate the values as Single and Double does.

Another way yo get absolute precision is to represent the values as
integer values multiplied by hundred. An Int is good for nine digits. A
Short only manages four digits, but it's even smaller than a Singe, so
you can use that if you really need to save memory.
 
Mark said:
A Single, not a Singe (unless, of course, you are talking about French
monkeys...)

:-)

Of course not. I was talking about a superficial burn injury. ;)
 
Back
Top