0

How come that 10/2=5.0 not 5?

little bit confused here.

6th Feb 2017, 9:03 AM
Ellaine Joyce Sorbito
Ellaine Joyce Sorbito - avatar
4 odpowiedzi
+ 3
JavaScript doesn't have a datatype defined on their own so it will always show a decimal part by default..
6th Feb 2017, 11:16 AM
Ashutosh Saraf
Ashutosh Saraf - avatar
+ 2
parseFloat(10/2).toFixed(1)
6th Feb 2017, 9:13 AM
ASNM
ASNM - avatar
+ 1
Javascript doesn't have an Integer, Float, Double, etc type on their own. All these types are part of the Number type. So the decimal part to the division will usually be displayed by default.
6th Feb 2017, 9:34 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
That's okay. Decimals .0 are same as normal integers.
6th Feb 2017, 1:16 PM
Mark
Mark - avatar