+ 1
What do we mean by the expression that JavaScript numbers are always stored as double precision floating point?
10 Antworten
+ 2
It’s in the lesson Ipang.
In languages like Java, C, C++ etc., there are three main types of numbers: ints, floats, and doubles. A double is more precise than a float, meaning it can store more decimal points. So, JS numbers are doubles.
+ 2
Because computers only understand binary, numbers are stored in base 2 (binary), which is made up of 0’s and 1’s.
An integer (int) is a whole number, and in most programming languages, if you try to put a decimal place in an int, it will raise an error.
A float is a floating-point number, which means that it can have decimal places.
A double (double-precision number) has more bits, so it can store more precise numbers - e.g. more than 10 decimal places.
In JavaScript, numbers are doubles by default
+ 2
That's gr8! Thanks so much 4 being there.
+ 2
Nice of you, Ipang. True, like minds work alike.
+ 2
++b will increase b by 1 then return the value.
Example:
var b = 5;
var x = ++b;
// b: 6
// x: 6
However, b++ will return the value THEN increase b by 1.
Example:
var b = 5;
var x = b++;
// b: 6
// x: 5
+ 1
In the lesson of course. Thanks
+ 1
Just adding a bit of additional info here 👇
https://www.w3schools.com/js/js_numbers.asp
https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/number
+ 1
Can someone clarify further on the 'increment operator': if placed after an operand, returns the original value and then increments the operand.
For clarity:
var x = 0, b= 10,
var x = ++b. // increment operator before.
document.write(b);
// outputs ?
again
var x = b++ // increment operator after.
(document.write (b); // outputs ?
Please bear with me, I am a beginer in JavaScript.
0
Where did you read this can you tell? is it in the lesson or somewhere else?
0
Dear, give illustration please.