Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Semrush - keyword research tool

Turn ChatGPT, Claude, Gemini, And CoPilot Into Your Personal Assistant, Business Coach, Content Creator, And More

AFFILIATE MARKETING Your all-in-one performance engine Manage affiliates, creators, and customer referrals in one unified platform—turning every partnership into measurable growth
Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

42,690 questions

55,449 answers

573 users

How to define an exabyte constant in JavaScript

1 Answer

0 votes
/*
    JavaScript Numbers are IEEE‑754 doubles.
    They can represent integers exactly only up to 2^53 - 1.

    Exabyte sizes:

        1 EiB = 2^60  = 1,152,921,504,606,846,976 bytes
        1 EB  = 10^18 = 1,000,000,000,000,000,000 bytes

    Both exceed 2^53, so we use BigInt for exact values.
*/

// Binary exabyte (exbibyte), using a BigInt bit shift.
// 1n << 60n = 2^60 bytes.
const EXABYTE_EIB = 1n << 60n;

// Decimal exabyte (SI), using a readable BigInt literal.
const EXABYTE_EB = 1_000_000_000_000_000_000n;

console.log("1 EiB =", EXABYTE_EIB, "bytes");
console.log("1 EB  =", EXABYTE_EB,  "bytes");



/*
run:

1 EiB = 1152921504606846976n bytes
1 EB  = 1000000000000000000n bytes

*/

 



answered May 3 by avibootz
...