As I read it, C99 states that a byte is an:
"addressabl e unit of data storage large enough to hold any member of
the basic character
set of the execution environment" (3.6)
and that a byte must be at least 8 bits:
"The values given below shall be replaced by constant expressions
suitable for use in #if
preprocessing directives. Moreover, except for CHAR_BIT and
MB_LEN_MAX, the
following shall be replaced by expressions that have the same type as
would an
expression that is an object of the corresponding type converted
according to the integer
promotions. Their implementation-defined values shall be equal or
greater in magnitude
(absolute value) to those shown, with the same sign."
number of bits for smallest object that is not a bit-field (byte)
CHAR_BIT 8 (5.2.4.2.1)
Does this mean that a byte can be larger than 8 bits (ie CHAR_BIT >
8)? I have gotten the impression that a byte, or unsigned char, was
always 8 bits, but perhaps I was wrong. If I am not, is there
somewhere in the standard that defines a byte as always being 8 bits?
Regards,
B.
Oct 1 '07
77 4298
Charlie Gordon wrote:
"Mike Smith" <mi*********@no .spam.btconnect .coma écrit dans le message de
news: Lt************* *************** **@bt.com...
>The hardware is Bull DPS9000 (a descendant of the Honeywell L66 range that was itself a descendant of the GE-600). The GCOS8 operating system is still in active use today.
The current generation of Bull DSP9000 (NovaScale 9xxx) machines run Gcos8
in emulation mode on Intel Itanium 2 processors. Not exactly the old 36 bit
architecture anymore.
GCOS8 under emulation in an Itanium!
This can ONLY be possible at Bull. Of course they HAD to choose
the Itanic, they have chosen ALL weird architectures born dead
since 1982... or more!
If something is bad conceived, eventually Bull will buy it, that
is obvious. The Itanic is a total failure, and Bull will chose
it.
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique http://www.cs.virginia.edu/~lcc-win32
jacob:
Given you don't care about porting from one version of windows to the
next, it's hardly suprising you don't care about this.
Martin
????
lcc-win runs under
o windows 2000
o windows 98
o windows XP (32 and 64 bits)
o windows server 32 and 64 bits
o windows Vista (32 and 64 bits)
It even runs under windows ME!
Linux versions are available. You just speak without any
knowledge of what I am doing.
I'm speaking of your experience with using int instead of size_t, and
the headache it caused you when you got truncation warning when you
ported to another windows version.
When I myself am writing code, I put in casts wherever I'm going to
get an obvious truncation warning. For instance:
#define MONTHS_IN_YEAR 12
char unsigned start_month = 4; /* A value in the range 0 through
11, 0 = Jan, 11 = Dec */
unsigned months_passed = 183; /* A value in the range 0 through
1800 */
char unsigned current_month = (char unsigned)(start _month +
months_passed % MONTHS_IN_YEAR)
/* Cast to suppress truncation warning */
Given the choice of
a) Using size_t
and
b) Using casts
, you chose neither, and ended up with 5 billion warning when you
compiled your code. Granted, the code may still have been portable,
but I'm sure you could have done without those redundant warnings.
Martin
"Martin Wells" <wa****@eircom. neta écrit dans le message de news: 11************* ********@k79g20 00...legro ups.com...
jacob:
Given you don't care about porting from one version of windows to the
next, it's hardly suprising you don't care about this.
Martin
???? lcc-win runs under o windows 2000 o windows 98 o windows XP (32 and 64 bits) o windows server 32 and 64 bits o windows Vista (32 and 64 bits)
It even runs under windows ME!
Linux versions are available. You just speak without any knowledge of what I am doing.
I'm speaking of your experience with using int instead of size_t, and
the headache it caused you when you got truncation warning when you
ported to another windows version.
When I myself am writing code, I put in casts wherever I'm going to
get an obvious truncation warning. For instance:
#define MONTHS_IN_YEAR 12
char unsigned start_month = 4; /* A value in the range 0 through
11, 0 = Jan, 11 = Dec */
unsigned months_passed = 183; /* A value in the range 0 through
1800 */
char unsigned current_month = (char unsigned)(start _month +
months_passed % MONTHS_IN_YEAR)
/* Cast to suppress truncation warning */
The need for these casts is a real pain. I'm glad gcc does not produce them
unless you specifically require them. In this particular case, I think your
computation is wrong, the line should read:
unsigned char current_month = (start_month + months_passed) %
MONTHS_IN_YEAR;
Written this way, it would not take a smart compiler to figure the result
should be in the range 0..11 and therefore always fits in an unsigned char.
Given the choice of
a) Using size_t
and
b) Using casts
, you chose neither, and ended up with 5 billion warning when you
compiled your code. Granted, the code may still have been portable,
but I'm sure you could have done without those redundant warnings.
Given the non-sensical choice made for win64 to have
sizeof(long)==s izeof(int)==4 and sizeof(size_t)= =sizeof(long long)==8,
mixing int and size_t irresponsibly is not a wise choice.
Furthermore, I think there should be provision in the compiler to enable or
disable each individual warning, either with a command line switch, a
configuration file option or possibly a #pragma.
--
Chqrlie.
jacob navia wrote:
Martin Wells wrote:
>jacob:
>>Of course, there are maybe 10-20 installations all over the world, but... I would not care really.
Given you don't care about porting from one version of windows to the next, it's hardly suprising you don't care about this.
????
lcc-win runs under
o windows 2000
o windows 98
o windows XP (32 and 64 bits)
o windows server 32 and 64 bits
o windows Vista (32 and 64 bits)
It even runs under windows ME!
No it doesn't. I can't speak for other combinations, but W98 runs
on a '486. lcc-win32 does not.
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net>
--
Posted via a free Usenet account from http://www.teranews.com
Keith Thompson wrote:
>
Kenneth Brody <ke******@spamc op.netwrites:
Keith Thompson wrote:
[...]
A small quibble: Putting C identifiers or keywords in all-caps for
emphasis is not a good idea. void is a keyword; VOID is an identifier
and could very plausibly be a macro name (for example, I've seen code
that conditionally uses ``#define VOID int'' for pre-ANSI
compatibility).
BTDTGTHF.
?
It's my update to "BTDTGTTS":
Been There, Done That, Got The Header Files.
--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer .h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th***** ********@gmail. com>
CBFalconer wrote:
jacob navia wrote:
>Martin Wells wrote:
>>jacob:
Of course, there are maybe 10-20 installations all over the world, but... I would not care really. Given you don't care about porting from one version of windows to the next, it's hardly suprising you don't care about this.
???? lcc-win runs under o windows 2000 o windows 98 o windows XP (32 and 64 bits) o windows server 32 and 64 bits o windows Vista (32 and 64 bits)
It even runs under windows ME!
No it doesn't. I can't speak for other combinations, but W98 runs
on a '486. lcc-win32 does not.
lcc-win32 should run in windows 98 unless you use a 486
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique http://www.cs.virginia.edu/~lcc-win32
Chqrlie:
In this particular case, I think your
computation is wrong, the line should read:
unsigned char current_month = (start_month + months_passed) %
MONTHS_IN_YEAR;
Well let's say that the starting month is April (i.e. 3), and that 14
months have passed. Therefore, the new month should be May (i.e. 5)
Taking *my* formula, we have:
start_month + months_passed % MONTHS_IN_YEAR
3 + 14 % 12
3 + 2
5
Taking *your* formula, we have:
(start_month + months_passed) % MONTHS_IN_YEAR
(3 + 14) % 12
17 % 2
5
Both work.
Written this way, it would not take a smart compiler to figure the result
should be in the range 0..11 and therefore always fits in an unsigned char.
....but the question is what proportion of compilers do it? For now I
think I'll stick to the casts.
Martin
"CBFalconer " <cb********@yah oo.coma écrit dans le message de news: 47************* **@yahoo.com...
jacob navia wrote:
>Martin Wells wrote:
>>jacob:
Of course, there are maybe 10-20 installations all over the world, but... I would not care really.
Given you don't care about porting from one version of windows to the next, it's hardly suprising you don't care about this.
???? lcc-win runs under o windows 2000 o windows 98 o windows XP (32 and 64 bits) o windows server 32 and 64 bits o windows Vista (32 and 64 bits)
It even runs under windows ME!
No it doesn't. I can't speak for other combinations, but W98 runs
on a '486. lcc-win32 does not.
Come on, W98 does not run on a '486, it merely crawls there like a lame dog.
--
Chqrlie.
Martin Wells <wa****@eircom. netwrites:
Chqrlie:
In this particular case, I think your
computation is wrong, the line should read:
unsigned char current_month = (start_month + months_passed) %
MONTHS_IN_YEAR;
Well let's say that the starting month is April (i.e. 3), and that 14
months have passed. Therefore, the new month should be May (i.e. 5)
Let's take another example: the starting month is December ie 11 and 11
months have passed. Therefore the new month should be November (10).
Taking *my* formula, we have:
start_month + months_passed % MONTHS_IN_YEAR
11 + 11 % 12 = 11 + 11 = 22. Oops
Taking *your* formula, we have:
(start_month + months_passed) % MONTHS_IN_YEAR
(11 + 11) % 12 = 22 % 12 = 10
Both work.
Not on all inputs.
Yours,
--
Jean-Marc
Jean-Marc:
Taking *my* formula, we have:
start_month + months_passed % MONTHS_IN_YEAR
11 + 11 % 12 = 11 + 11 = 22. Oops
Now that's what I call a logic bug. :O
Martin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: w3r3w0lf |
last post by:
hello!
I have a following situation:
I have a byte array where at a certain location are stored 4 bytes, and
these should be "put" into long variable (or any other 4 byte one).
ie:
byte a={0x0,0x0,0xfe,0x30,0x9e,0x2,0x66,0,0}
and the bytes 0xfe,0x30,0x9e,0x2 should be put into long variable which
should then contain 43921662
how to achieve this?
|
by: napi |
last post by:
I think you would agree with me that a C compiler that directly
produces Java Byte Code to be run on any JVM is something that is
missing to software programmers so far. With such a tool one could
stay with C and still be able to produce Java byte code for
platform independent apps. Also, old programs (with some tweaking)
could be re-compiled and ported to the JVM.
We have been developing such a tool over the last 2 years and currently...
|
by: Samuel Thomas |
last post by:
Hello Friends,
I understand(could be wrong) that the smallest chunk of memory is
called a word. If that is correct, that means if I am using a 32 bit
OS a word is 4 bytes. So that's why the size of an int is 4 bytes. How
is it that a char then gets 1 byte. Shouldn't it also get 4 bytes even
though it might be able to store only 256 values? Is the OS doing some
sort of trimming?
Thanks
|
by: Kapil Khosla |
last post by:
Hi,
I am trying to reverse a byte eg.
11010000 should look like
00001011
Plz note, it is not a homework problem and I do not need the c code
for it.
Just give me an idea how should I proceed about it.
I know basic bit manipulation , shifting left, right and have done
|
by: s.subbarayan |
last post by:
Dear all,
I would like to know the easiest efficient way to set or inject a
particular value in the given word or byte?The problem is:
I have to implement a function which will set a value from position
"n" to "n+x" where n and x are passed dynamically,where n is start
position of the bit from which i will be setting a value and x is the
position where I will be finishing the setting.In short it looks like
this:
| |
by: Benjamin M. Stocks |
last post by:
Hello all,
I've heard differing opinions on this and would like a definitive
answer on this once and for all. If I have an array of 4 1-byte values
where index 0 is the least signficant byte of a 4-byte value. Can I use
the arithmatic shift operators to hide the endian-ness of the
underlying processor when assembling a native 4-byte value like
follows:
unsigned int integerValue;
unsigned char byteArray;
|
by: david ullua |
last post by:
I am reading "Joel on Software" these days, and am in stuck with the
question of "how to calculate bitsize of a byte" which is listed as one
of the basic interview questions in Joel's book. Anyone could give some
ideas?I am expecting your reply.
David.
|
by: rsood |
last post by:
Hi
I'm developing a program, and naturally I want it to be as portable as
possible. I need to be able to access specific numbers of bytes in it,
but as far as I know, there is no keyword in the c language such as
'byte'. Is it always okay to assume that the char data type is always
1 byte, or is there some other way to be sure you are getting 1 byte
that is not processor/OS dependent that is better, or is there no way
to be both...
|
by: quantumred |
last post by:
I found the following code floating around somewhere and I'd like to
get some comments.
unsigned char a1= { 5,10,15,20};
unsigned char a2= { 25,30,35,40};
*(unsigned int *)a1=*(unsigned int *)a2;
// now a1=a2, a1=a2, etc.
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |