> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# JavaScript Number

In JavaScript, the `Number` type is a numeric data type representing both integer and floating-point values. Under the hood, all `Number` values are implemented as double-precision 64-bit floating-point formats conforming to the IEEE 754 standard. While modern JavaScript includes the `BigInt` type specifically for arbitrary-precision integers, the `Number` type itself does not distinguish between integers and floats. Consequently, all operations on `Number` values are subject to floating-point arithmetic rules and limitations.

## Memory Architecture (IEEE 754)

A JavaScript `Number` consumes 64 bits of memory, divided into three components:

* **Sign:** 1 bit (determines positive or negative).
* **Exponent:** 11 bits (determines the magnitude).
* **Mantissa (Fraction/Significand):** 52 bits (determines the precision).

Although only 52 bits are allocated in memory for the mantissa, normalized IEEE 754 numbers use an *implicit* leading bit of `1` that is not stored. This hidden bit effectively provides 53 bits of precision, allowing the `Number` type to safely represent integers between `-(2^53 - 1)` and `2^53 - 1`. Values outside this range are subject to precision loss.

## Instantiation and Syntax

Numbers can be created via literals, the `Number` function (for type coercion), or the `Number` constructor (which creates an object wrapper).

```javascript theme={"dark"}
// 1. Numeric Literals (Primitive)
const int = 42;
const float = 3.14;
const hex = 0xff;        // Base 16
const binary = 0b1010;   // Base 2
const octal = 0o744;     // Base 8
const scientific = 1.5e3 // 1500

// 2. Number Function (Type Coercion to Primitive)
const coerced = Number("42");     // 42
const coercedBool = Number(true); // 1

// 3. Number Constructor (Object Wrapper - Generally Avoided)
const numObj = new Number(42); 
typeof int;    // "number"
typeof numObj; // "object"
```

## Special Numeric Values

The `Number` type includes several special values defined by the IEEE 754 standard:

```javascript theme={"dark"}
const notANumber = NaN;          // Result of an invalid mathematical operation
const posInf = Infinity;         // Result of dividing a positive number by 0
const negInf = -Infinity;        // Result of dividing a negative number by 0
const posZero = +0;              // Standard zero
const negZero = -0;              // Negative zero (behaves identically to +0 in most cases)
```

## Static Properties

The `Number` constructor holds several static properties representing architectural limits and constants.

```javascript theme={"dark"}
Number.MAX_SAFE_INTEGER;  // 9007199254740991 (2^53 - 1)
Number.MIN_SAFE_INTEGER;  // -9007199254740991 (-(2^53 - 1))
Number.MAX_VALUE;         // 1.7976931348623157e+308 (Largest representable number)
Number.MIN_VALUE;         // 5e-324 (Smallest positive representable number)
Number.EPSILON;           // 2.220446049250313e-16 (Difference between 1 and the smallest floating point number greater than 1)
Number.NaN;               // Special "Not a Number" value
Number.POSITIVE_INFINITY; // Infinity
Number.NEGATIVE_INFINITY; // -Infinity
```

## Static Methods

Static methods are called directly on the `Number` object and are primarily used for type checking and parsing.

```javascript theme={"dark"}
// Parsing
Number.parseInt("42.9px", 10); // 42 (Parses string to integer, accepts radix)
Number.parseFloat("42.9px");   // 42.9 (Parses string to float)

// Type and Value Checking
Number.isFinite("42");         // false (Does not coerce types, unlike global isFinite("42") which returns true)
Number.isFinite(Infinity);     // false (Infinity is not a finite number)
Number.isInteger(42.0);        // true
Number.isInteger(42.1);        // false
Number.isNaN("NaN");           // false (Does not coerce types, unlike global isNaN("NaN") which returns true)
Number.isNaN(NaN);             // true
Number.isSafeInteger(9007199254740992); // false (Exceeds 2^53 - 1)
```

## Instance Methods

Instance methods are inherited from `Number.prototype` and are used to format or convert numeric primitives. When called on a primitive, JavaScript temporarily wraps the primitive in a `Number` object to execute the method.

```javascript theme={"dark"}
const num = 123.456;

// Returns a string representing the number in exponential notation
num.toExponential(2); // "1.23e+2"

// Returns a string representing the number with fixed-point notation
num.toFixed(2);       // "123.46" (Rounds the fractional part)

// Returns a string representing the number to a specified precision (total digits)
num.toPrecision(4);   // "123.5"

// Returns a string representation of the number in the specified radix (base)
num.toString(16);     // "7b.74bc6a7ef9db2" (Hexadecimal representation)

// Returns the primitive value of the Number object
num.valueOf();        // 123.456
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor JavaScript Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
