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

If an integer is positive or negative

How will i know in C programming if an integer is negative or positive?
Apr 20 '10 #1

✓ answered by RedSon

If it is greater than zero it will be positive and if it is less than zero it will be negative.

6 3450
RedSon
5,000 Expert 4TB
If it is greater than zero it will be positive and if it is less than zero it will be negative.
Apr 20 '10 #2
donbock
2,426 Expert 2GB
no details
Please provide some details. What exactly is your question?
Apr 20 '10 #3
jkmyoung
2,057 Expert 2GB
... you ask the program?

... the first bit of the integer will be set if it is negative. If it is not set, the number is non-negative. If the integer is zero, none of the bits will be set.
Apr 20 '10 #4
RedSon
5,000 Expert 4TB
I think mine is the best answer. I'm choosing it, because I'm awesome!
Apr 20 '10 #5
donbock
2,426 Expert 2GB
... the first bit of the integer will be set if it is negative. If it is not set, the number is non-negative ...
This is only true if signed integers are encoded using two's-complement. Although two's-complement is ubiquitous, it is not mandated by the C Standard. This approach is not portable.
Apr 20 '10 #6
RedSon
5,000 Expert 4TB
Oooh don throws a right hook at jkm!! Will he parry or duck?

He may be down for the count folks!

(can you tell I'm having fun?)
Apr 20 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: Imbaud Pierre | last post by:
integer division and modulo gives different results in c and python, when negative numbers are involved. take gdb as a widely available c interpreter print -2 /3 0 for c, -1 for python. more...
9
by: Lord Merlin | last post by:
Sorry for the dumb question, but what is the function in ASP to see if an object / string is an integer? I want to check the contents of a form, and if it's an integer, i.e a number, do...
18
by: Mark R Rivet | last post by:
can someone tell me why on a signed int the range is -32768 to +32768. why do we get one more in the negative. I understand it takes two bytes of memory.
25
by: bruce.james.lee | last post by:
hi i have a problem with integer subtraction in C. printf("%d", c < (a - b)); a is got from a #define and is 0x80000000 and b is got from input and is also 0x80000000. c is ffffffff (-1). Now,...
3
by: Janice | last post by:
I got this question from my textbook and I cannot understand the theory. When a signed positive integer X divided by pow(2,k), the result is shifting k bits to right and putting w-k bits of 0 from...
15
by: jaks.maths | last post by:
How to convert negative integer to hexadecimal or octal number? Ex: -568 What is the equivalent hexadecimal and octal number??
19
by: Robbie Hatley | last post by:
For your enjoyment, a function that expresses any integer with absolute value less-than-or-equal-to nine quintillion in any base from 2 to 36. (For larger bases, you could expand the "digit"...
15
by: Ivan Novick | last post by:
Hi, Is it possible to have negative integer literal or only positive? As far as I understand, the code below would be a positive integer literal and the unary negative operator. x = -3.2; ...
1
by: haelly | last post by:
write a program that prompts the user to enter three different positive integer values.If the values are not different, the program prints a message"equal value" and terminates(hint:use the return...
1
by: vijjirams | last post by:
Hi All, May I know what is the difference between Small integer and Capital integer. Thanks in advance Regards, -vijji
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
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...

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.