Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

MySQL Help - how to store decimal

Thread Tools
 
Search this Thread
 
Old Sep 24, 2004 | 11:06 AM
  #1  
chump's Avatar
chump
Thread Starter
Scooby Regular
 
Joined: Feb 2004
Posts: 266
Likes: 0
Default MySQL Help - how to store decimal

I want to store a decimal number (i.e. 8.5 or 11.4) in a mySQL database but I'm unsure what datatype to use and can't figure it out. Whatever I choose it rounds the figure up.

Can anyone suggest what I need to do?

Chump
Reply
Old Sep 24, 2004 | 11:16 AM
  #2  
Mickle's Avatar
Mickle
Scooby Regular
25 Year Member
 
Joined: Jan 2001
Posts: 2,029
Likes: 0
From: Warwickshire
Default

float, double, decimal

FLOAT [(M,D)]
A FLOAT represents small decimal numbers, used when a somewhat more precise representation of a number is required.

ex.
rainfall FLOAT (4,2);
This could be used to represent rainfall average in centimeters per year, which could be a decimal value. More specifically, FLOAT (4,2) states the fact that rainfall can hold up to four characters and two decimal places. Thus,

42.35 is valid, accurately represented.
324.45 is invalid, rounded to 324.5.
2.2 is valid, accurately represented.
34.542 is invalid, rounded to 34.54.

Note: Due to the fact that FLOAT is rounded, those wishing to represent money values would find it wise to use DECIMAL, a datatype found within MySQL that does not round values. Consult the documentation for a complete explanation.


http://dev.mysql.com/tech-resources/...datatypes.html
Reply
Old Sep 24, 2004 | 11:29 AM
  #3  
Dream Weaver's Avatar
Dream Weaver
Scooby Regular
25 Year Member
Liked
 
Joined: Feb 2000
Posts: 9,846
Likes: 4
From: Lancashire
Default

Double is also fine for currency, or as above Decimal(10,2), meaning 1111111111.22
Reply
Old Sep 24, 2004 | 12:23 PM
  #4  
chump's Avatar
chump
Thread Starter
Scooby Regular
 
Joined: Feb 2004
Posts: 266
Likes: 0
Default

nice one that fixed it!
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
KAS35RSTI
Subaru
27
Nov 4, 2021 07:12 PM
alcazar
Non Scooby Related
7
Oct 2, 2015 06:08 PM
Wurzel
Computer & Technology Related
10
Sep 28, 2015 12:28 PM
Littleted
Computer & Technology Related
4
Sep 25, 2015 09:55 PM
the shreksta
Non Car Related Items For sale
1
Sep 19, 2015 01:39 PM




All times are GMT +1. The time now is 01:32 AM.