473,395 Members | 1,756 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,395 software developers and data experts.

Is this part of the standard?

Is the "-" operator (meaning * (-1) ) part of the standard?

Example program:

#include <stdio.h>

int main(void)
{
int a = -5;

printf("%d", -a); /* should print 5 */

return 0;
}
Is that portable?
Feb 5 '06 #1
3 1177
copx a écrit :
Is the "-" operator (meaning * (-1) ) part of the standard?


Yes.
Feb 5 '06 #2
copx wrote:
Is the "-" operator (meaning * (-1) ) part of the standard?
Yes (C&V 6.5.3). It's called "unary minus" (same as in maths, really).
Example program:

#include <stdio.h>

int main(void)
{
int a = -5;

printf("%d", -a); /* should print 5 */

return 0;
}
Is that portable?


No, as you did not terminate `printf` with '\n'. Not doing so makes it
possible for a conforming implementation to do anything, including not
printing out any characters at all. ;-)

As for a unary `-`, yes, it is.

Cheers

Vladimir

--
That woman speaks eight languages and can't say "no" in any of them.
-- Dorothy Parker

Feb 5 '06 #3

"copx" <in*****@invalid.com> schrieb im Newsbeitrag
news:ds*************@news.t-online.com...
Is the "-" operator (meaning * (-1) ) part of the standard?

[snip]

Thank you for the answers!

Feb 5 '06 #4

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

Similar topics

1
by: red floyd | last post by:
In the August 2004 CUJ, Sutter&Hyslop's column implies that shared_ptr<> has become part of the standard. Is the revised standard finalized? Am I correct in assuing that shared_ptr<> will be...
6
by: Rebecca Smith | last post by:
Today’s question involves two time text boxes each set to a different time zone. Initially txtCurrentTime will be set to Pacific Time or system time. This will change with system time as we travel...
2
by: maxw_cc | last post by:
Hi to all of you, I was wondering what the Semantics part in C standard is really for? What should be on the constraints part and what should be on the semantics part? Is the implementation...
50
by: Romeo Colacitti | last post by:
Is the C library of most OSes (i.e, unix type OSes) implemented at the very low kernel or just outside kernel level? Looking through the source tree of Linux/BSDs it seems like the C library is...
7
by: Stanley S | last post by:
Hi, Are Signal Handling part of ANSI C? I am not able to find any reference of Sig Handling in Stephen Prata's "C Primer Plus". The usage of signals is to trap errors I guess. (It looks...
3
by: blackswift | last post by:
Hello all, I know STL is part of the standard. Is STL a part of C++ language? I heard scanf function is not a part of C. Best regards.
5
by: itsolution | last post by:
Following is a snippet of FreeBSD man page. It seems to indicate search.h is a part of Standard C library. True? What's the exact list of Standard C library headers? Looks like most modent OS...
3
by: albert.neu | last post by:
Hello! The C99 library is part of C++ TR1. From: http://www.dinkumware.com/tr1.aspx comes this information: "C99 library, including all the numerous functions added to the C Standard with...
8
by: Nomen Nescio | last post by:
Hey, this is Ajun from a Bangladesh outsource company. Han has hired me to do the English writing for his comp.lang.c posts. The subject line has been changed, which may affect archival...
35
by: Lew Pitcher | last post by:
On November 14, 2008 15:00, in comp.lang.c, Nomen Nescio (nobody@dizum.com) wrote: Overkill Try
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
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...

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.