473,495 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to define the range of integer variable?

3 New Member
We know that in 16bit compiler integer variable have 2bytes(16 bits).First MSB for sign and other 15bits for value.By converting this 15bit to value we can get only (-16384 to 16383).Then how can we get the range (-32768 to 32767)??.....please help me to deal with this.
Dec 12 '10 #1
2 6091
johny10151981
1,059 Top Contributor
your math was wrong

the output you got is equivalent to
pow(2,14)

try the mathe
pow(2,15)

you will get the answer for sure
Dec 12 '10 #2
donbock
2,426 Recognized Expert Top Contributor
The range of values that fit into the various types is implementation dependent. The Standard requires each implementation to explicitly specify its integer ranges with the macros of header file limits.h. (Floating point ranges are specified in float.h.)

The Standard mandates a certain minimum range for each data type, but each implementation is free to make the ranges larger. These minimum ranges are described at the limits.h link.

"We know that in 16bit compiler integer variable have 2bytes(16 bits).First MSB for sign and other 15bits for value"
Do not assume any particular encoding scheme. How negative numbers are encoded and whether there is a sign bit are implementation dependent. Your code will be nonportable if you try to make use of special knowledge like that.
Dec 12 '10 #3

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

Similar topics

2
2549
by: Roger Lord | last post by:
I am constructing a string in my program and then trying to use it to get the value of an integer variable whose label looks like that string. I can't figure out how to do it. For example: Dim...
12
8424
by: obdict | last post by:
Hello, I have a simple C question regarding scanf() /* What happens if user inputs a char when he/she is supposed * to input an integer? */ #include<stdio.h> int main(void){ int n;
2
2199
by: awrightus | last post by:
I am trying to incorporate a integer variable with a vb.net datetime literal. For example: Dim Jan1 As DateTime = (#1/1/2006#) would be a literal for January 1st of this year. But I have a...
3
4689
by: tirrell payton | last post by:
Hello all, I have a question about the concatenation operator in C#. For example, I want to concatenate an integer variable to a control. I have an integer, i. I have checkboxes, checkbox0 -...
12
5862
by: Monty | last post by:
Hope this is an easy one: How can I bind a text on a form to a an integer variable? Possible? Thanks!
3
2588
by: DeerGuy | last post by:
This is a really, really simple question, but I so new to VBA, that I have to ask. I have an integer variable that I want to perform some actions on depending upon its value. Is the following...
34
11261
by: Cuthbert | last post by:
Hi folks, I am trying to find a more efficient way to count "How many bits are '1' in a integer variable?". I still have no idea to count the bits except using a loop and "if" statements....
2
4434
by: Mike OKC | last post by:
VB.NET 2003 I'm new to VB.NET, so this should be an easy fix. My integer variable showing &HA when I hover the mouse pointer over the variable, and also shown in Locals, Name: intLoop Value: &HA...
7
5781
by: Lee Sander | last post by:
Hi, I would like to define a new variable which is not predefined by me. For example, I want to create an array called "X%s" where "%s" is to be determined based on the data I am processing....
3
3747
by: yhvh | last post by:
I want to generate a range with variable leading zeros x = padding = len(x) for j in range(x, x): print (url).join('%0(pad)d(jj)'+'.jpg') %{'pad':padding, 'jj':j}
0
7120
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
7160
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
5456
agi2029
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,...
1
4897
isladogs
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...
0
4583
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1405
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 ...
1
649
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
286
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.