473,326 Members | 2,148 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Basic C question

Reading C99 6.2.6.2:
Is integer promotion value-preserving or bit-pattern-preserving?
What is (unsigned)NEGATIVE_ZERO provided it is supported?

--
Thanks,
Ark
Oct 30 '07 #1
5 1288

"Ark Khasin" <ak*****@macroexpressions.comwrote in message
news:VzAVi.3628$MW.2448@trndny05...
Reading C99 6.2.6.2:
Is integer promotion value-preserving or bit-pattern-preserving?
value preserving, though often both are equivalent.

What is (unsigned)NEGATIVE_ZERO provided it is supported?
this is implementation specific...

possible options:
0
0xFFFFFFFF (or, all 1s, for 1s complement systems)
0x80000000 (MSB set, others 0, for sign-magnitude systems)
....

--
Thanks,
Ark
Oct 30 '07 #2
"cr88192" <cr*****@nospam.hotmail.comwrites:
"Ark Khasin" <ak*****@macroexpressions.comwrote in message
news:VzAVi.3628$MW.2448@trndny05...
>Reading C99 6.2.6.2:
Is integer promotion value-preserving or bit-pattern-preserving?

value preserving, though often both are equivalent.
>What is (unsigned)NEGATIVE_ZERO provided it is supported?

this is implementation specific...

possible options:
0
0xFFFFFFFF (or, all 1s, for 1s complement systems)
0x80000000 (MSB set, others 0, for sign-magnitude systems)
...
It looks like you're assuming that the conversion preserves the
representation. In two's-complement, it generally does, but in
general negative zero has a *value* of 0, and converting 0 to unsigned
must yield 0U. Padding bits might permit representations for 0U other
than all-bits-zero, but all-bits-zero must be a representation of the
value 0U.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Oct 30 '07 #3
Ark Khasin <ak*****@macroexpressions.comwrites:
Reading C99 6.2.6.2:
Is integer promotion value-preserving or bit-pattern-preserving?
Value preserving: see C99 6.3.1.
What is (unsigned)NEGATIVE_ZERO provided it is supported?
0u.
--
char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa6 7f6aaa,0xaa9aa9f6,0x11f6},*p
=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)break;else default:continue;if(0)case 1:putchar(a[i&15]);break;}}}
Oct 30 '07 #4

"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
"cr88192" <cr*****@nospam.hotmail.comwrites:
>"Ark Khasin" <ak*****@macroexpressions.comwrote in message
news:VzAVi.3628$MW.2448@trndny05...
>>Reading C99 6.2.6.2:
Is integer promotion value-preserving or bit-pattern-preserving?

value preserving, though often both are equivalent.
>>What is (unsigned)NEGATIVE_ZERO provided it is supported?

this is implementation specific...

possible options:
0
0xFFFFFFFF (or, all 1s, for 1s complement systems)
0x80000000 (MSB set, others 0, for sign-magnitude systems)
...

It looks like you're assuming that the conversion preserves the
representation. In two's-complement, it generally does, but in
general negative zero has a *value* of 0, and converting 0 to unsigned
must yield 0U. Padding bits might permit representations for 0U other
than all-bits-zero, but all-bits-zero must be a representation of the
value 0U.
yes, but afaik, whether it preserves the type or the value is afaik
implementation defined (I don't know, unless maybe the standard requires it
to correctly preserve the value in this case?).

that is why '0' was listed as well (should have probably said "most
likely").

--
Keith Thompson (The_Other_Keith) ks***@mib.org
<http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*>
<http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Nov 2 '07 #5
cr88192 wrote:
>
"Keith Thompson" <ks***@mib.orgwrote in message
>>
It looks like you're assuming that the conversion preserves the
representation. [...]

yes, but afaik,
You don't know far enough.
whether it preserves the type or the value is afaik
implementation defined
You don't know far enough.
(I don't know,
Congratulations! You're right!
unless maybe the standard requires
it to correctly preserve the value in this case?).
You would do well to re-read whatever textbook or other
source you learned C from. Or "sort of learned" C from.

--
Eric Sosman
es*****@ieee-dot-org.invalid
Nov 2 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: pauldepstein | last post by:
I am reading Grimshaw and Ortega's "C++ and Numerical Methods." They construct a vector class which contains the variable vec, a float* variable where the length of the array (number of...
6
by: DH | last post by:
I have a VERY basic question about figuring database size. I've inherited a database which is generally similar to this basic one: Item, Red, Blue, Green, Yellow (text), (int),(int),(int),(int)...
9
by: Malcolm | last post by:
After some days' hard work I am now the proud possessor of an ANSI C BASIC interpreter. The question is, how is it most useful? At the moment I have a function int basic(const char *script,...
4
by: Ramesh | last post by:
hi, Let me ask some basic questions. Can anybody explain me about the following questions: 1. When we have to create sn key? Whenever we compiled Component we have to create or it is a one time...
13
by: Pete | last post by:
I'm cross posting from mscom.webservices.general as I have received no answer there: There has been a number of recent posts requesting how to satisfactorily enable BASIC authorization at the...
5
by: Aussie Rules | last post by:
Hi, Having a mental block on this one. Have done it before but can't rack my brain on how... I have an object, with a bunch on property, and I add that object to a combo box. I want the...
4
by: MikeB | last post by:
I've been all over the net with this question, I hope I've finally found a group where I can ask about Visual Basic 2005. I'm at uni and we're working with Visual Basic 2005. I have some books, ...
1
by: frankhanretty | last post by:
Do I have to install Visual basic on the remote terminals as I did on the server? I have an visual basic 5 application running fine on my client's server and he is now networked. He wants to run the...
4
by: Chris Asaipillai | last post by:
Hi there My compay has a number of Visual Basic 6 applications which are front endeed onto either SQL Server or Microsoft Access databases. Now we are in process of planning to re-write these...
3
by: Scott Stark | last post by:
Hello, I'm trying to get a better handle on OOP programming principles in VB.NET. Forgive me if this question is sort of basic, but here's what I want to do. I have a collection of Employee...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.