Javascript and the big integer imprecision… or the WTF with my mysql ids ?

Ever tried to send mysql id over json ? just some small things to know before you try…

open a javascript console and type the following:

first try a stupid echo :

 > 23278053098520650

hum ok echo is not working correctly

Let’s try with a number object:

 > 23278053098520650

again… ok it is a too big number, let see what is the max:

 > 1.7976931348623157e+308

wow javascript can handle really big number… but with an imprecision of 16 digits and of course mysql ids are 17 digits… so you have to handle mysql ids as string.

Auteur/autrice : Chrystophe Vergnaud

Prendre du recul pour identifier les réels besoins et faire un choix technologique en fonction de ces besoins.

Laisser un commentaire