decimal precision and scale

# Thread: decimal precision and scale

1. Member
Join Date
Dec 1969
Posts
79

## decimal precision and scale

Re: MS SQL 2K<BR><BR>My data will range from 0 to 99.5 - but will typically be 1 thru 4 (and all the .5&#039;s in between).<BR><BR>I am assuming decimal is the best data type choice here. Should I be explicitly setting the precision and scale. Or is the default acceptable for my use? I have it has decimal(10,2) now.<BR><BR>I ask this because I am having a problem with the Command Object (.asp/vbs) and want to make sure my data type choices are ideal first.

2. Senior Member
Join Date
Dec 1969
Posts
11,247

## RE: decimal precision and scale

depends on what you are using it for!<BR><BR>How can I say?

3. Member
Join Date
Dec 1969
Posts
79

## I thought...

I thought the expected data determines what data type to use.<BR><BR>Being that I know what the data will be (1.5, 2, 2.5, 3, etc) I thought someone could let me know if my choice was out of line or plain wrong.<BR><BR>I used decimal with precision-10 and scale-2. I wanted to cover my needs and allow extra room in case my expectations are off.<BR><BR>I guess by your answer my choice is not "wrong."<BR><BR>Thanks

4. Senior Member
Join Date
Dec 1969
Posts
11,247

## RE: I thought...

How many Decimal places do you need?<BR><BR>Only you can answer that !<BR><BR>But the data type is correct as you have data with decimal places!

5. Senior Member
Join Date
Dec 1969
Posts
96,118

## VBScript can't do DECIMAL...

...so if you read records with fields of this type back into ASP/ADO/VBS, you&#039;ll have to convert the fields to double floating point. Luckily, you *can* do this in VBS, as the CDBL() [and other such conversion functions] simply call a COM function that *is* capable of recognizing non-VBS data types.<BR><BR>But, actually, for a range of 0 to 99.5, where the numbers are always N.0 or N.5, you could use FLOAT or DOUBLE just as well and just as accurately. Floating point numbers that are actually integers or where the fractional part is made up of negative powers of two (e.g., 1/2, 1/4, 1/8, 7/8 [1/2 + 1/4 + 1/8], etc.) are correctly represented with no loss of precision.<BR><BR><BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•