interconnectit / Search-Replace-DB

This script was made to aid the process of migrating PHP and MySQL based websites. Works with most common CMSes.
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
GNU General Public License v3.0
4k stars 855 forks source link

change in double numbers? (round) #253

Closed foxontherock closed 4 years ago

foxontherock commented 5 years ago

Hi, I just used the tool to change some strings. And, before going "live", I looked at the suggested changes. I didn't see the word I was trying to replace. So I searched why is my data changing, and I found this:

d:64.950000000000003; becomes d:64.95;

In fact, I'm happy that these numbers will be "rounded", I am sure that the 00000003 was an error.

But my question is, why are you replacing these double/float numbers instead of leaving them unchanged?

pe-pe80 commented 5 years ago

Hi, my problem: d:1.15 becomes d:1.149999999999999911182158029987476766109466552734375

PHP 5.6.3

RobKuipers commented 5 years ago

I had the exact same problem. It's due to the (de)serialization of data. Try adding ini_set('serialize_precision', -1); to index.php. That solved it for me.

gianluigi-icit commented 4 years ago

it's not an error, unfortunately computer have some problems with floating point numbers, we could eventually round the numbers