-
SitePoint Enthusiast
Updating a flot is strange
I noticed a strange problem, following is the table structure:
currencies_id int(11) NO PRI NULL auto_increment
title varchar(32) NO
code char(3) NO
symbol_left varchar(24) YES NULL
symbol_right varchar(24) YES NULL
decimal_point char(1) YES NULL
thousands_point char(1) YES NULL
decimal_places char(1) YES NULL
value float(13,8) YES NULL
last_updated datetime YES NULL
using PHPMyAdmin I executed the following update statement:
update currencies set title = 'US Dollar', code = 'USD', symbol_left = '$', symbol_right = '', decimal_point = '.', thousands_point = ',', decimal_places = '2', value = '48.3' where currencies_id = '1'
The value filed should store 48.30 after the successful execution but I noticed it is: 48.29999924.
For any floating value it is doing this, I tried it on my local installation as well but the same problem. Is it a MySQL Bug?
Am I doing something stupid?
Regards
-
Use decimal instead of float. Float is an aproximate datatype.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks