floats

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

floats

Post by m3rajk »

i'm adding two feilds to the statistics (stats table): 'past votes total' and 'past vote count'
since votes range from 1 to 10 inclusive in .5 increments, there's a need for a float. this is so that i can reset the votes, because one of the complaints i've heard about other places is that people can only vote once, another one is that one place it's once a day and the downvoters seem terrible there, so i figure once a month resetting the vote table would be a happy medium)

i need to use a float for that, but i don't know how many spaces a float can have. i don't see anything on the site and the book says it can be a number like 1.175494351e+38 but i don't know if they mean 10 spaces total or 48 (38 plus the ten shown)
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

In mysql I think that 1.175494351e+38 = 1.175494351 * 10 ^ 38 so i guess the actual num is 1 (int) + 9 (dec.).

But I'm not 100% so anyone else might want to add their thoughts.

Cant you use floor() or ceil() and round it abit for easier reading (and probably easier working with)? Looks wierd with those range. ;)
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

well the number i'll be workign with is only going to have one spot of percision (float(?,1)) the question really is, would 10 be the max, or does the book i have not give me the 38 places but use e+38 for their convience?
Post Reply