asmith Posted March 5, 2008 Share Posted March 5, 2008 hey guys i have a table , which has only 2 rows. a number column which is a float. both rows "number" column record is 0.1 . when i run this line in phpmyadmin : select number from table i get the 2 entries which is 0.1 . but when i run this line : select max(number) from table i get 0.10000000149012 any idea why ? and how can i fix it ? thanks a bunch Quote Link to comment Share on other sites More sharing options...
kenchucky Posted March 5, 2008 Share Posted March 5, 2008 This is because floats aren't accurate. The only solution is not to use floats. Quote Link to comment Share on other sites More sharing options...
asmith Posted March 6, 2008 Author Share Posted March 6, 2008 hmm so what to use instead of floats to handle this type of numbers? Quote Link to comment Share on other sites More sharing options...
aschk Posted March 6, 2008 Share Posted March 6, 2008 DOUBLE or NUMERIC perhaps. I've not done a lot with floats or otherwise to say which is best. Double might suffer from the same problem... Quote Link to comment Share on other sites More sharing options...
luca200 Posted March 6, 2008 Share Posted March 6, 2008 Double might suffer from the same problem... I think so Use DECIMAL Quote Link to comment Share on other sites More sharing options...
kenchucky Posted March 6, 2008 Share Posted March 6, 2008 Doubles are just bigger floats. They are still floats. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.