Delphi Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreDelphi Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 29th, 2003, 04:35 PM
acey acey is offline
Swede
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Location: Sweden
Posts: 47 acey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 12
Smile Binary record says what?

Hi!

This is not a Delphi question, but a Pascal question, but since Delphi is a sub language to Pascal I think it will fit in to this forum.

I'm storing a record ( one record ) in a file;
Code:
TYPE
     posttype = RECORD
            id : Integer;
            name : Packed Array[1..10] Of Char;
            data: Integer;
     END;

The binary value of this record in the file on the harddrive looks like this:
Code:
0000 0000 0000 0000 0000 0000 1000 1101
0101 0011 0111 0100 0110 0101 0111 0111
0110 0001 0111 0010 0111 0100 0010 0000
0010 0000 0010 0000 0000 0000 0000 0000
1111 1111 1111 1111 1111 1111 1111 1011

( Of course without the spaces )

What does this mean? How can I read this in plain english?

Thanks in advance.

Regards,

Reply With Quote
  #2  
Old October 29th, 2003, 11:29 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,389 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 22 h 17 m 29 sec
Reputation Power: 4080
Looks like a hex dump that you're showing there. Two hex digits represent the contents of one byte. Depending on your compiler, integer may be 2 or 4 bytes or whatever (16 bit vs. 32 bit vs. 64 bit of whatever the size of integer may be).

The packed keyword is to tell the compiler to squeeze the bits of a array as close together as possible. For example, ASCII chars are only 7 bits long, and if your byte is 8 bits long (on the original machine that Pascal was implemented in, it was something other than 8 bits to the byte), you could use the unused bits of the byte to store part of the next character in the array. Thus, if you squeezed all the bits together, you might save a few bytes in an array. IIRC Turbo Pascal ignored the packed keyword altogether and was perfectly happy wasting the unused bit per byte, so each character in an array would occupy precisely one byte, and it would leave the high bit of each byte unused. So, even if you have the same data in a packed array, different compilers may give you a different hex dump depending on whether they choose to obey or ignore the packed keyword for the array.
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > Binary record says what?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap