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

Largest possible value of Integer Constants

How can I get the largest possible value of the Integer Constants and use it
in the program for these types:
1. int
2. long
3. unsigned short

Thanks
Nov 13 '05 #1
7 7010
Nicholas wrote:
How can I get the largest possible value of the Integer Constants and use it
in the program for these types:
1. int
2. long
3. unsigned short


#include <limits.h>

INT_MAX, LONG_MAX, USHRT_MAX. And many more.

See http://www-ccs.ucsd.edu/c/limits.html .

--
Tom Zych
This email address will expire at some point to thwart spammers.
Permanent address: echo 'g******@cbobk.pbz' | rot13
Nov 13 '05 #2
Tom Zych wrote:
Nicholas wrote:

How can I get the largest possible value of the Integer Constants and use it
in the program for these types:
1. int
2. long
3. unsigned short

#include <limits.h>

INT_MAX, LONG_MAX, USHRT_MAX. And many more.

See http://www-ccs.ucsd.edu/c/limits.html .

To the OP: also note that if portability is one of your objectives, you
will want to use the minimal required values for those limits as
specified in the ISO C standard (e.g. 65536 for UINT_MAX, etc.).
--
Tom Zych
This email address will expire at some point to thwart spammers.
Permanent address: echo 'g******@cbobk.pbz' | rot13

Tom: nitpick. Your sig block looks ok, but is not (else it would have
been automatically cut away by my newsreader...): you need to have an
additional space character after those two dashes that start your sig block.

--
Bertrand Mollinier Toublet
"In regard to Ducatis vs. women, it has been said: 'One is a sexy thing
that you've just got to ride, even if it breaks down a lot, costs a lot
of money, and will probably try to kill you'. However, nowadays I can't
seem to remember which one is which." -- Peer Landa

Nov 13 '05 #3
Bertrand Mollinier Toublet wrote:
Tom: nitpick. Your sig block looks ok, but is not (else it would have
been automatically cut away by my newsreader...): you need to have an
additional space character after those two dashes that start your sig block.


Ah. I wondered why that space was there. Is that in an RFC or
something?

--
Tom Zych
This email address will expire at some point to thwart spammers.
Permanent address: echo 'g******@cbobk.pbz' | rot13
Nov 13 '05 #4
In <bj************@ID-168218.news.uni-berlin.de> Bertrand Mollinier Toublet <be*****************************@enst-bretagne.fr> writes:
Tom Zych wrote:
--
Tom Zych
This email address will expire at some point to thwart spammers.
Permanent address: echo 'g******@cbobk.pbz' | rot13

Tom: nitpick. Your sig block looks ok, but is not (else it would have
been automatically cut away by my newsreader...): you need to have an
additional space character after those two dashes that start your sig block.


Maybe he has, but his posting software was written in C ;-)

Whether space characters that are written out immediately before a
new-line character appear when read in is implementation-defined.

Requiring a space right before the end of the line in the sig block
separator was a brain dead idea in the first place. The posting software
I've used until this year simply dropped that space.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #5
Dan Pop wrote:
Whether space characters that are written out immediately before a
new-line character appear when read in is implementation-defined.


Are you saying that's part of the C standard? In what context?
It's hard to believe that's part of the standard - what if binary
data happens to contain \x20\x0a?

Anyway, my posting software (Netscape) isn't at fault. It precedes
a sig with "-- \n". I put "--\n" inside my sig block to separate
the sig I use for email from the sig I use when spammers will see
it.

--
Tom Zych
This email address will expire at some point to thwart spammers.
Permanent address: echo 'g******@cbobk.pbz' | rot13
Nov 13 '05 #6
Tom Zych <tz******@pobox.com> writes:
Dan Pop wrote:
Whether space characters that are written out immediately before a
new-line character appear when read in is implementation-defined.


Are you saying that's part of the C standard? In what context?
It's hard to believe that's part of the standard - what if binary
data happens to contain \x20\x0a?


It only applies to text streams, not binary streams.
--
"I'm not here to convince idiots not to be stupid.
They won't listen anyway."
--Dann Corbit
Nov 13 '05 #7
Ben Pfaff wrote:
It only applies to text streams, not binary streams.


! I wasn't aware that C made a distinction. Have to read more...

--
Tom Zych
This email address will expire at some point to thwart spammers.
Permanent address: echo 'g******@cbobk.pbz' | rot13
Nov 13 '05 #8

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

Similar topics

17
by: Adam H. Peterson | last post by:
Is there a standard way to find the minimum value for a data type? I'm thinking along the lines of std::numeric_limits<T>::min(). But that doesn't work for floating point types. I can't use...
13
by: Peter Ammon | last post by:
I have a floating point number. I'd like to get the nearest floating point number that is larger or smaller than the given number. I investigated FLT_EPSILON but it only seems to be useful if the...
7
by: dam_fool_2003 | last post by:
#include<stdio.h> int main(void) { unsigned int a=20,b=50, c = sizeof b+a; printf("%d\n",c); return 0; } out put: 24
19
by: ramu | last post by:
Hi, I have, suppose 1000 numbers, in a file. I have to find out 5 largest numbers among them without sorting. Can you please give me an efficient idea to do this? My idea is to put those numbers...
5
by: Gregory Piñero | last post by:
Hi Guys, I'm sure this is documented somewhere, I just can't locate it. Say I have this code: try: myfile=file('greg.txt','r') except IOError, error: #now psuedo code because this is what...
32
by: jamieexley | last post by:
what are the parameters needed in the constructor call below to create a Date variable whose intitial value is the 15th of March 2004????
3
by: HEMH6 | last post by:
Who can help solve this problem??? Finding the Largest Value (a) write a function, largest(), that returns the largest value in a signed integer array. The array and its size are passed as...
3
by: Steven W. Orr | last post by:
This is all an intro learning experience for me, so please feel free to explain why what I'm trying to do is not a good idea. In the Cookbook, they have a recipe for how to create global...
8
by: MLH | last post by:
Is there any built-in FN for returning largest value in a group of say 2 - 10 values? Lets say I want a FN something like MaxVal(5, 7, 9, 3, 12) or perhaps MaxVal(79,34). I would wanna see return...
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: 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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
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...
0
tracyyun
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...

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.