> ## 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.

# TypeScript number

The `number` type in TypeScript is a primitive data type that represents both integer and floating-point values. Inheriting JavaScript's numeric implementation, TypeScript evaluates all `number` values as IEEE 754 double-precision 64-bit floating-point formats. There is no distinct type for integers (e.g., `int` or `float`) within the standard `number` type.

## Literal Representations

TypeScript supports strict typing for base numeral systems and scientific notation using specific literal formats:

```typescript theme={"dark"}
// Decimal (Base 10)
const decimal: number = 42;
const float: number = 3.14159;

// Scientific / Exponential Notation
const sci: number = 1e10;
const sciNegative: number = 2.5e-3;

// Hexadecimal (Base 16) - Prefix: 0x or 0X
const hex: number = 0x2A;

// Binary (Base 2) - Prefix: 0b or 0B
const binary: number = 0b101010;

// Octal (Base 8) - Prefix: 0o or 0O
const octal: number = 0o52;
```

## Numeric Separators

To improve the readability of large numeric literals, TypeScript supports the ECMAScript numeric separator feature. Underscores (`_`) can be used to visually group digits, but they must be placed strictly between two digits. They cannot appear at the beginning or end of a literal, adjacent to a decimal point, adjacent to a base prefix, or consecutively. These separators are stripped out during compilation and do not affect the underlying value.

```typescript theme={"dark"}
// Valid separators
const billions: number = 1_000_000_000;
const bytes: number = 0xFF_00_00_FF;
const fractional: number = 0.000_001;

// Invalid separators (will cause compilation errors)
// const invalidStart = _100;      // Cannot start with a separator
// const invalidDecimal = 1_.5;    // Cannot be adjacent to a decimal point
// const invalidPrefix = 0x_A;     // Cannot be adjacent to a base prefix
// const invalidConsecutive = 1__0; // Cannot be consecutive
```

## Special Numeric Values

The `number` type encompasses several special global properties that result from specific mathematical operations or represent boundary limits:

```typescript theme={"dark"}
const notANumber: number = NaN;               // Result of undefined math operations (e.g., 0/0)
const positiveInfinity: number = Infinity;    // Exceeds upper bound of floating-point representation
const negativeInfinity: number = -Infinity;   // Exceeds lower bound of floating-point representation
```

## Precision and Bounds

Because `number` relies on a 64-bit floating-point format, it can only safely represent integers between `-(2^53 - 1)` and `2^53 - 1`.

```typescript theme={"dark"}
const maxSafe: number = Number.MAX_SAFE_INTEGER; // 9007199254740991
const minSafe: number = Number.MIN_SAFE_INTEGER; // -9007199254740991
```

Integers outside this boundary will experience precision loss. For arbitrary-precision integers, TypeScript provides a distinct `bigint` primitive, which is not strictly compatible with `number` without explicit coercion.

## Primitive vs. Wrapper Object

TypeScript distinguishes between the lowercase `number` primitive and the uppercase `Number` global wrapper object. Type annotations should always use the lowercase `number` to avoid assigning an object reference where a primitive value is expected.

```typescript theme={"dark"}
// Correct: Primitive type annotation
let primitiveNum: number = 10;

// Incorrect: Object wrapper type annotation (Avoid)
let objectNum: Number = new Number(10); 
```

<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 TypeScript 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>
