Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7666605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:52:32+00:00 2026-05-31T14:52:32+00:00

I have next code: type TRecord1 = record myarr: array [0..31] of single: end;

  • 0

I have next code:

type TRecord1 = record
  myarr: array [0..31] of single:
end;
type TRecord2 = record
  b1, b2, b3, b4, b5, b6: byte;
end;
type TRecord3 = record
  myarr: array [0..31] of single:    
  b1, b2, b3, b4, b5, b6: byte;
end;

procedure TForm1.FormCreate(Sender: Tobject);
begin
  ShowMessage(IntToStr(SizeOf(TRecord1))+'+'+IntToStr(SizeOf(TRecord2))+
      '='+IntToStr(SizeOf(TRecord3)));
end;

The program shows the following message:

128+6=136

Why is SizeOf(TRecord3) equal to 136 rather than 134?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T14:52:33+00:00Added an answer on May 31, 2026 at 2:52 pm

    This is due to padding added because of record alignment. TRecord3 has alignment of 4 since it contains single values. And so padding is added to the end of the record to make the size an exact multiple of 4. That’s why the size is 136 rather than the value of 134 that you were expecting.

    You can declare your record to be packed, or, equivalently, set the alignment compiler option to $ALIGN 1. With an alignment of 1 there will be no padding added to the record and SizeOf(TRecord3)=134. However, I strongly recommend you do not do this. Using the natural alignment results in the most efficient memory access for records. For example, it is more expensive for the processor to load a misaligned value than to load an aligned value. For a single or an integer, the natural alignment is on a 4 byte bounday. For a double the natural alignment is on an 8 byte boundary and so on. You should use packed records if you need binary compatibility with another library that uses packed records.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a next code: type THead = packed record znmpc: byte; znmpcch: array
I have thi next code, but he doesn't work: $select_sell = $this->select(); $select_sell->from($this->_name, array('rank_id'))
I have next code require 'rack/rpc' class Server < Rack::RPC::Server def hello_world Hello, world!
I have the next code in javascript. I deleted some unnecessary items because it
I have the next code: Process p = Runtime.getRuntime().exec(args); and I want my program
I have the next code that was given to me to split up a
I have a next code in my view: <% @todos.each do |todo| %> <tr>
I have the next code: js: $('[id^=check-]').change(function(){ var new_id = this.id.replace(/check/, 'new'), real_id =
i have the next code: std::string line; std::ifstream myfile (text.txt); if (myfile.is_open()) { while
I have a fairly simple block of code. Sub Run(Name) on error resume next

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.