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

Create your online store today with Shopify

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

Disclosure: My content contains affiliate links.

43,563 questions

56,781 answers

573 users

How to define a petabyte constant in Pascal

1 Answer

0 votes
program PetabyteConstantExample;

{
  In Free Pascal, the largest unsigned integer type is QWord (64‑bit).
  A petabyte fits comfortably inside 64 bits:

    1 PiB = 2^50  = 1,125,899,906,842,624 bytes
    1 PB  = 10^15 = 1,000,000,000,000,000 bytes
}

const
  // Binary petabyte (pebibyte), using a bit shift.
  // 1 shl 50 = 2^50 bytes.
  PETABYTE_PIB: QWord = QWord(1) shl 50;

  // Decimal petabyte (SI petabyte), using a plain numeric literal.
  // No digit separators, for maximum compatibility.
  PETABYTE_PB: QWord = 1000000000000000;

var
  sizeBinary: QWord;
  sizeDecimal: QWord;

begin
  sizeBinary := PETABYTE_PIB;
  sizeDecimal := PETABYTE_PB;

  WriteLn('1 PiB = ', sizeBinary, ' bytes');
  WriteLn('1 PB  = ', sizeDecimal, ' bytes');
end.



(* 
run:

1 PiB = 1125899906842624 bytes
1 PB  = 1000000000000000 bytes

*)

 



answered May 2 by avibootz
...