develooper Front page | perl.dbi.users | Postings from March 2008

mysql inserting decimal value with perl loses precision

Thread Next
From:
myrose.20.ftumsh
Date:
March 14, 2008 02:51
Subject:
mysql inserting decimal value with perl loses precision
Lo,

This is more for the archives than anything as there is a workaround.

When inserting 1234567890.123456 into a decimal(16,6) column, the value 
stored is 1234567890.123460

Having a brainwave from the Time::HiRes docs,
sprintf('%.6f', 1234567890.123456) stores the expected value.

Is this expected behaviour or should DBD::mysql automagically do the 
right thing?

John

Thread Next


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About