It’s 2021 week 36, I recently had a bit of fun with JavaScript number data type and Malaysia Day is around the corner (16th September) - that’s how I arrive at this week’s topics. Here are some interesting facts about numbers in JavaScript and numbers related to the Malaysian flag.
JavaScript number: the primitive data type
number
is based on the IEEE 754 standard, which means floating-point arithmetic applies. The classic example is0.1 + 0.2
returns0.30000000000000004
, the result also shows the decimal precision limit of 17.JavaScript bigint: the
bigint
primitive type was introduced in ES2020, it can safely represent integers bigger thanNumber.MAX_SAFE_INTEGER
, e.g.9007199254740992 === 9007199254740993
returnstrue
which is wrong but with BigInt,9007199254740992n === 9007199254740993n
returnsfalse
as expected. Note that as of current, theMath
object doesn't work withbigint
.The Malaysian flag: before the formation of Malaysia in year 1963, the flag for Federation of Malaya had 11 stripes and the star had 11 points as opposed to 14 for both now. The original submission of the design had a five-pointed star.
This is my 9th weekly post, thank you for reading and if you have got any feedback, do let me know!
Related Links
- JavaScript data types and data structures by MDN contributors.
- Math - Javascript by MDN contributors.
- The History and Design Chronology of JALUR GEMILANG by Muhamad Razif Nasruddin and Zarul Nazli bin Zulkhurnain.
Top comments (0)