Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Decimal or Double ??

Status
Not open for further replies.

MaryChan

Programmer
Jan 4, 2001
9
SG
hi,

I want to insert numeric values into MS Access2K database
that will be able capture up to 2 decimal places.

So I set the data type for that particular fld to be "Number" and set it to decimal.

however, it doesn't seem to capture the last 2 digitals in the decimal place.

i.e. 30.25 when inserted into the database read 30


in view of this, I have to reset the data type to double instead.

why is this so?
 
When you click on the Number data type next to your field. Press the F6 key
Now down t the bottom you will see Integer.
Click that box and several choices pop up
Double and single are good for decimal numbers
The size of your number depends on which you choose
Double is one humongous number
Single is almost as large
Integer is 32,000 to –32,000 (roughly)

DougP, MCP
dposton@universal1.com

Ask me how Bar-codes can help you be more productive.
 
good day !!

thanks for the information.

so does that mean that every time I want to store a number with decimal places, I have to set it to Double ???

if this is so, then where does the Decimal comes in ??

so what is Bar-codes all abt and how can it aid me in my development ??



Tks.

 
MaryChan,

I don't quite understand this, but from reading the help files, doubles store a wider range of numbers than decimals, but doubles are stored as 8 bytes whereas decimals are stored as 12 bytes.

When I first learnt all of this, I was basically told that if you need to store decimal numbers use double. data types used to be a factor many moons ago when disk space / memory was more of an issue in programming than it is today with high spec machines.
Simon
 
Simon -

The only thing to remember about doubles vs. numbers is that doubles are stored as an approximation, and numbers are exact. If you were to store a currency value in a double, it would be subject to rounding, something a bank's customers might not like. B-(

Mary - Do like DougP says and set the number of positions to the right of the decimal point by pressing F6. The location of the decimal point is stored in the column definition, not in the data. When your program accesses it, the database will format it correctly before it gives it to you.

Chip H.
 
I stumbled across something interesting, Access 2000 added a new different Data type in the numbers area called Decimal. Access ’97 does not have it.

So that’s why I was talking about double and single

here is a screen capture to show you.


I use ’97 mostly.

DougP, MCP
dposton@universal1.com

Ask me how Bar-codes can help you be more productive.
 
chiph,
I recently (this week) had a rounding issue with a data type of single. I was importing data from FoxPro to Access and when I had a number which had 6 digits before the decimal point and 2 digits after the decimal point, it was imported as 6 digits.1 digit, rounding the number to the nearest tenth. I changed the data type to double and this solved the problem.

All I have to do now is debug the application as the screen that displays the information is also rounding these numbers to 6.1 format!!
Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top