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 Link to comment https://forums.phpfreaks.com/topic/94499-select-and-max-difference/ 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. Link to comment https://forums.phpfreaks.com/topic/94499-select-and-max-difference/#findComment-484160 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? Link to comment https://forums.phpfreaks.com/topic/94499-select-and-max-difference/#findComment-484654 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... Link to comment https://forums.phpfreaks.com/topic/94499-select-and-max-difference/#findComment-484741 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 Link to comment https://forums.phpfreaks.com/topic/94499-select-and-max-difference/#findComment-484753 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. Link to comment https://forums.phpfreaks.com/topic/94499-select-and-max-difference/#findComment-484778 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.