brandonboyce Posted January 31, 2011 Share Posted January 31, 2011 I have some numbers such as 44.1, 44.2, 44.3,.....,44.10, 44.11 where I need to keep the last zero in the 44.10. My trouble is that if I set the data type as a decimal with 2 decimal places 44.1 becomes 44.10 which I don't want and if I save the data type as float then my 44.10 becomes 44.1. I have been able to retain the trailing zero by saving data as text but then it doesn't sort properly 16.x comes before 2.x. Hopefully someone can make sense of what I am trying to accomplish, thanks in advance for any help provided. Quote Link to comment https://forums.phpfreaks.com/topic/226239-retaining-zeros/ Share on other sites More sharing options...
corbin Posted January 31, 2011 Share Posted January 31, 2011 The easiest solution is to just use number_format() on in the application code instead of doing it at a database level. Quote Link to comment https://forums.phpfreaks.com/topic/226239-retaining-zeros/#findComment-1168094 Share on other sites More sharing options...
DavidAM Posted February 1, 2011 Share Posted February 1, 2011 If you are trying for sequential numbers, shouldn't that be 44.01, 44.02, 44.03 ... 44.09, 44.10, 44.11? Otherwise they are just strings. Quote Link to comment https://forums.phpfreaks.com/topic/226239-retaining-zeros/#findComment-1168193 Share on other sites More sharing options...
brandonboyce Posted February 8, 2011 Author Share Posted February 8, 2011 Sorry for the delayed reply, I've been caught up on other projects...anyway @DavidAM yes the data SHOULD be formatted like that unfortunately the existing data isn't and I am not able to change it. @corbin thanks for the suggestion I will look into number_format and see what I can do. Quote Link to comment https://forums.phpfreaks.com/topic/226239-retaining-zeros/#findComment-1171403 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.