I retreive two values from a table each of mysql type DECIMAL(2,2). I then add these values but if the value is something like $5.50 it just prints $5.5! as these refer to money it is important they show any trailing 0s
thank in advance
DECIMAL types - displaying 0s
Moderator: General Moderators
-
penguinboy
- Forum Contributor
- Posts: 171
- Joined: Thu Nov 07, 2002 11:25 am
DECIMAL(X,Y)
The X is the length of the number of characters stored, including the '-' negative sign.
Ex: -100.00 is 6 characters long.
Ex: 1000.00 is 6 characters long.
The Y is the number of characters beyond the decimal point.
Ex: -100.00 is 2 characters long.
Ex: -100.000 is 3 characters long.
So for numbers ranging from -999.99 through 9999.99 your colum should be DECIMAL(6,2)
DECIMAL(10,2)
Would be
-9999999.99 through
99999999.99
The X is the length of the number of characters stored, including the '-' negative sign.
Ex: -100.00 is 6 characters long.
Ex: 1000.00 is 6 characters long.
The Y is the number of characters beyond the decimal point.
Ex: -100.00 is 2 characters long.
Ex: -100.000 is 3 characters long.
So for numbers ranging from -999.99 through 9999.99 your colum should be DECIMAL(6,2)
DECIMAL(10,2)
Would be
-9999999.99 through
99999999.99