Streaming live at 10am (PST)

Number fields adding decimal points


#1

Hey,

Number fields for weights in my “Products” collection are spontaneously updating to have more decimal places than I entered, which changes the weight and subsequently shipping costs of products in customers’ carts.

I had this issue before and thought it was solved by entering no more than the number of decimal points specified in the collection template but it’s reared its head again and I can’t see why.

Anyone see what is causing this? Seems like a pretty drastic response from the CMS and causes a lot of unwanted effects.


Here is my public share link: https://preview.webflow.com/preview/tailored-prints?utm_source=tailored-prints&preview=23181119f98b4fe5f722bb8673569386


#2

Yeah that’s a very well-known JavaScript bug.

Stuff like this can happen: 0.1 + 0.2 -> 0.30000000000000004

See:

Is floating point math broken?

How to deal with floating point number precision in JavaScript?