Is there a datatype for byte?
I want to write an API that takes in an array of bytes.
I can use char array, but not sure if sizeof(char) will always be 1
now or in future on all machines(32/64bit) and compilers.
Is sizeof(char) always gauranteed to be one?
Thanks. 7 11645
lazy wrote:
Is there a datatype for byte?
I want to write an API that takes in an array of bytes.
I can use char array, but not sure if sizeof(char) will always be 1
now or in future on all machines(32/64bit) and compilers.
Is sizeof(char) always gauranteed to be one?
sizeof(char) is guaranteed to be one.
However, a char is not guaranteed to be an octet of bits.
Best
Kai-Uwe Bux
On 1 Apr, 08:24, Kai-Uwe Bux <jkherci...@gmx.netwrote:
lazy wrote:
Is there a datatype for byte?
I want to write an API that takes in an array of bytes.
I can use char array, but not sure if sizeof(char) will always be 1
now or in future on all machines(32/64bit) and compilers.
Is sizeof(char) always gauranteed to be one?
sizeof(char) is guaranteed to be one.
However, a char is not guaranteed to be an octet of bits.
It is, however, guaranteed to have an object (and value)
representation of exactly one byte.
DP
On Mar 31, 11:41 pm, Triple-DES <DenPlettf...@gmail.comwrote:
On 1 Apr, 08:24, Kai-Uwe Bux <jkherci...@gmx.netwrote:
lazy wrote:
Is there a datatype for byte?
I want to write an API that takes in an array of bytes.
I can use char array, but not sure if sizeof(char) will always be 1
now or in future on all machines(32/64bit) and compilers.
Is sizeof(char) always gauranteed to be one?
sizeof(char) is guaranteed to be one.
However, a char is not guaranteed to be an octet of bits.
It is, however, guaranteed to have an object (and value)
representation of exactly one byte.
DP
Thanks.
On Apr 1, 8:24 am, Kai-Uwe Bux <jkherci...@gmx.netwrote:
lazy wrote:
Is there a datatype for byte?
I want to write an API that takes in an array of bytes.
I can use char array, but not sure if sizeof(char) will always be 1
now or in future on all machines(32/64bit) and compilers.
Is sizeof(char) always gauranteed to be one?
sizeof(char) is guaranteed to be one.
However, a char is not guaranteed to be an octet of bits.
Neither is a byte. I've seen bytes of 6, 7 and 9 bits as well,
and on a PDP-10, the size of a byte was programmable.
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
On 2008-04-01 14:58, James Kanze wrote:
On Apr 1, 8:24 am, Kai-Uwe Bux <jkherci...@gmx.netwrote:
>lazy wrote:
Is there a datatype for byte?
I want to write an API that takes in an array of bytes.
I can use char array, but not sure if sizeof(char) will always be 1
now or in future on all machines(32/64bit) and compilers.
Is sizeof(char) always gauranteed to be one?
>sizeof(char) is guaranteed to be one.
>However, a char is not guaranteed to be an octet of bits.
Neither is a byte. I've seen bytes of 6, 7 and 9 bits as well,
and on a PDP-10, the size of a byte was programmable.
I think, however, that the minimal size of a char in C++ is 7 bits since
the standard identifies at least 99 characters in the basic character
set which must be encodable in a char (sections 2.2 and 3.9.1 in the
standard).
--
Erik Wikström
On Tue, 01 Apr 2008 18:30:19 GMT, Erik Wikström
<Er***********@telia.comwrote in comp.lang.c++:
On 2008-04-01 14:58, James Kanze wrote:
On Apr 1, 8:24 am, Kai-Uwe Bux <jkherci...@gmx.netwrote:
lazy wrote:
Is there a datatype for byte?
I want to write an API that takes in an array of bytes.
I can use char array, but not sure if sizeof(char) will always be 1
now or in future on all machines(32/64bit) and compilers.
Is sizeof(char) always gauranteed to be one?
sizeof(char) is guaranteed to be one.
However, a char is not guaranteed to be an octet of bits.
Neither is a byte. I've seen bytes of 6, 7 and 9 bits as well,
and on a PDP-10, the size of a byte was programmable.
I think, however, that the minimal size of a char in C++ is 7 bits since
the standard identifies at least 99 characters in the basic character
set which must be encodable in a char (sections 2.2 and 3.9.1 in the
standard).
No, the minimum size of a char in C++ is 8 bits. Unfortunately, you
can't gather that directly from the C standard.
You can gather that from 18.2.1.2 (see footnotes 181 and 182 in C++
98, might have different numbers in later versions).
Then you go to 18.2.2 where the C++ incorporates <climitswith the
statement "The contents are the same as the Standard C library header
<limits.h>."
When the C++ standard incorporates a C header, any C95 requirements
apply in C++, unless specifically excluded by text in the C++
standard. In this case, there are no such exclusions, so one can look
up a copy of the C95 standard and find out that C++ requires a minimum
value of 8 for CHAR_BIT.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
On Apr 1, 8:30 pm, Erik Wikström <Erik-wikst...@telia.comwrote:
On 2008-04-01 14:58, James Kanze wrote:
On Apr 1, 8:24 am, Kai-Uwe Bux <jkherci...@gmx.netwrote:
lazy wrote:
Is there a datatype for byte?
I want to write an API that takes in an array of bytes.
I can use char array, but not sure if sizeof(char) will always be 1
now or in future on all machines(32/64bit) and compilers.
Is sizeof(char) always gauranteed to be one?
sizeof(char) is guaranteed to be one.
However, a char is not guaranteed to be an octet of bits.
Neither is a byte. I've seen bytes of 6, 7 and 9 bits as well,
and on a PDP-10, the size of a byte was programmable.
I think, however, that the minimal size of a char in C++ is 7
bits since the standard identifies at least 99 characters in
the basic character set which must be encodable in a char
(sections 2.2 and 3.9.1 in the standard).
The C and C++ standards use a non-standard definition of byte.
They require a byte to have at least 8 bits (since the smallest
legal value of UCHAR_MAX is 255); they also speak of bytes
regardless of the implementation, where as of course, many early
machines didn't have bytes at all. (Thus, for example, when a
DSP defines CHAR_BIT as 32, and sizeof( int ) == sizeof( char ),
the C/C++ standard speaks of 32 bit bytes, when according to the
traditional definition, there are no bytes, just words.)
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: David Cook |
last post by:
Java's InetAddress class has some methods that use
a byte-array to hold what it describes as a 'raw IP address'.
So, I assume that they mean an array like:
byte ba = new byte;
would hold an...
|
by: intrepid_dw |
last post by:
Hello, all.
I've created a C# dll that contains, among other things, two functions
dealing with byte arrays. The first is a function that returns a byte
array, and the other is intended to...
|
by: Dennis |
last post by:
I was trying to determine the fastest way to build a byte array from
components where the size of the individual components varied depending on
the user's input. I tried three classes I built: (1)...
|
by: moondaddy |
last post by:
I need to convert a byte array to a string and pass it as a parameter in a
URL and then convert it back to the original byte array. However, its
getting scrambled in the conversion. In short,...
|
by: johannblake |
last post by:
I have a variable that is 1 bit wide. I also have a variable that is a
byte. I want to shift the bits out of the byte into the bit variable
(one at a time) but am not sure how to do this or whether...
|
by: Frederick Gotham |
last post by:
What do you think of the following code for setting and retrieving the
value of bytes in an unsigned integer? The least significant bit has
index 0, then the next least significant bit has index 1,...
|
by: MimiMi |
last post by:
I'm trying to decrypt a byte array in java that was encrypted in C#. I don't get any error messages, just a result that's completely not what I was hoping for.
I think I am using the same type of...
|
by: MimiMi |
last post by:
I'm trying to decrypt a byte array in java that was encrypted in C#. I don't get any error messages, just a result that's completely not what I was hoping for.
I think I am using the same type of...
|
by: Scott Townsend |
last post by:
So I need to talk to a devices that expects all of the bits and bytes I sent
it to be in specific places (not yet 100% defined).
I wanted to create a structure/class with all of the data in it...
|
by: O.B. |
last post by:
When using Marshal to copy data from a byte array to the structure
below, only the first byte of the "other" array is getting copied from
the original byte array. What do I need to specify to get...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |