Logo

Programming-Idioms

History of Idiom 79 > diff from v36 to v37

Edit summary for version 37 by 1.7.4:
[JS] Made explanation better

Version 36

2019-01-23, 19:03:18

Version 37

2019-01-23, 19:04:22

Idiom #79 Convert integer to floating point number

Declare floating point number y and initialize it with the value of integer x .

Idiom #79 Convert integer to floating point number

Declare floating point number y and initialize it with the value of integer x .

Code
let y = x + .0
Code
let y = x + .0
Comments bubble
You might say "Wait! All javascript numbers are floats!"
They certainly always behave like floats on the outside, but modern javaScript engines can internally represent some numbers as integers.
Comments bubble
You might say "Wait! All JavaScript numbers are floats!"
They certainly always behave like they are on the outside, but on the inside they treat some numbers as integers.