var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: MySQL Data type for percent
I am trying to set up 2 columns.
One is for Price in US dollars.
Two is for the percent markup (of the above Price).
$100.00 for Price
10.5% for percent markup
So the resulting purchase price would be Price plus percent markup.
In this case it would be $110.50
I understand that DECIMAL 4,2 would be the approprate data type for the Price column.
What would be appropriate data type for the percent markup column?
Use decimal for that as well. You would write 10.5% as .105
you would need to use decimal (4,3) for that as you might need to represent a 100% or more markup.
Also you might find you need to use the round() function when doing your calculations to get the right number of decimals for your price.
the largest number that decimal(4,2) can hold is 99.99
the largest number that decimal(4,3) can hold is 9.999
Well I was thinking that he would represent 10% as .1 and 100% as 1.00, the ,3 would be needed to represent the third digit of 1/2 percent as .005
Too many baseball stats for me I guess, since I'm used to representing a '300' batting average as .300
Last edited by guelphdad; 05-09-04 at
yeah, i realize that, dave, it's just that he said he wanted to represent his price as decimal(4,2), and i concluded that he assumed this was 4 digits left of the decimal point and two to the right, so i thought i would clarify for his sake