473,761 Members | 8,813 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

unsigned long long

Is the unsigned long long primitive data type supported in ANSI
standard C?

I've tried using it a couple of times in standard C, but to no avail.
I'm using both MS VIsual C++ 6, as well as the gcc compiler that comes
with RedHat linux 9.

If not, what data type will yield the largest unsigned integer for me?

Thanks for your help,

Rich
Nov 13 '05
29 19619

"Dan Pop" <Da*****@cern.c h> wrote in message
news:bo******** **@sunnews.cern .ch...
In <z4************ *****@news04.bl oor.is.net.cabl e.rogers.com> "Tom St Denis" <to********@iah u.ca> writes:
"Joona I Palaste" <pa*****@cc.hel sinki.fi> wrote in message
news:bo******* ***@oravannahka .helsinki.fi...
Tom St Denis <to********@iah u.ca> scribbled the following:
> "Joona I Palaste" <pa*****@cc.hel sinki.fi> wrote in message
> news:bo******** **@oravannahka. helsinki.fi...
>> > ANSI is old. I for one welcome our new ISO overlords.
>>
>> I would think that the difference between the ANSI and ISO versions of >> the C standard is entirely bureaucratic and has no effect on the
>> technical content.

> Be that as it may "unsigned long long" is part of ISOC AFAIK.

ISO C99, Tom. Not ISO C90.


Tom assumes we're dealing with the latest not the oldest.


An excellent illustration of the point I've made in another thread.


Tom von Tom has ways of making you talk!

Tom
Nov 13 '05 #21

Get your Server or Homepage now

Choose which one you prefer.
Redhat, Debian, FreeBSD, Mandrake, Windows, SUSE
http://www.comserver.net
Nov 13 '05 #22
Jonathan2s6 <jo*********@ao l.com> scribbled the following:
Get your Server or Homepage now Choose which one you prefer.
Redhat, Debian, FreeBSD, Mandrake, Windows, SUSE


Get lost.

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"A bee could, in effect, gather its junk. Llamas (no poor quadripeds) tune
and vow excitedly zooming."
- JIPsoft
Nov 13 '05 #23
Dan Pop wrote:

In <3F***********@ earthlink.net> Joe Wright <jo********@ear thlink.net> writes:
Try this.

/*
Sizes of various things in bits..
*/
#include <stdio.h>
#include <limits.h>

int main(void) {
unsigned int a, b, c;
unsigned long long x, y, z;

c = -1;
b = 1 << (sizeof(int)*CH AR_BIT-1);
a = ~b;

z = -1;
y = 1LL << (sizeof(long long)*CHAR_BIT-1);
x = ~y;

printf("Size of void = %2lu bits\n", sizeof(void) *
CHAR_BIT);
printf("Size of char = %2lu bits\n", sizeof(char) *
CHAR_BIT);
printf("Size of short = %2lu bits\n", sizeof(short) *
CHAR_BIT);
printf("Size of int = %2lu bits\n", sizeof(int) *
CHAR_BIT);
printf("Size of long = %2lu bits\n", sizeof(long) *
CHAR_BIT);
printf("Size of long long = %2lu bits\n", sizeof(long long) *
CHAR_BIT);
printf("Size of int * = %2lu bits\n", sizeof(int *) *
CHAR_BIT);
printf("Size of char * = %2lu bits\n", sizeof(char *) *
CHAR_BIT);
printf("Size of void * = %2lu bits\n", sizeof(void *) *
CHAR_BIT);
printf("Size of float = %2lu bits\n", sizeof(float) *
CHAR_BIT);
printf("Size of double = %2lu bits\n", sizeof(double) *
CHAR_BIT);
printf("Size of long double = %2lu bits\n", sizeof(long double) *
CHAR_BIT);
printf("Max int = %11d\n", a);
printf("Min int = %11d\n", b);
printf("Max unsigned int = %11u\n", c);
printf("Max long long = %20lld\n", x);
printf("Min long long = %20lld\n", y);
printf("Max unsigned long long = %20llu\n", z);
return 0;
}


Try it yourself, with the compiler in conforming mode, this time!

Come on Dan, lighten up. As you have noted elsethread, we are not likely
to have C99 conformance. Vanilla gcc compiles this fine. With -ansi
-pedantic it complains about 'long long' of course. I've already
forgotten why I felt compelled to post code here.
--
Joe Wright http://www.jw-wright.com
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 13 '05 #24
Da*****@cern.ch (Dan Pop) wrote in message news:<bo******* ***@sunnews.cer n.ch>...
In <bo**********@s parta.btinterne t.com> Richard Heathfield <do******@addre ss.co.uk.invali d> writes:
<snip>
Apart from Eric's comments, you may find it a good idea to cast the
expression sizeof(char) * CHAR_BIT to unsigned long before passing it to a
variadic function such as printf.


Or, more generally, to the actual type expected by the respective
conversion description.

Unless you're using a conforming C99 implementation, there is no
conversion description that is guarantee to properly handle a size_t
value. Even worse, in the case of sizeof(type) * CHAR_BIT, the type
of the expression can be either size_t or int.


....or unsigned int.

--
Peter
Nov 13 '05 #25
In <63************ **************@ posting.google. com> ai***@acay.com. au (Peter Nilsson) writes:
Da*****@cern.c h (Dan Pop) wrote in message news:<bo******* ***@sunnews.cer n.ch>...
In <bo**********@s parta.btinterne t.com> Richard Heathfield <do******@addre ss.co.uk.invali d> writes:
> <snip>
>Apart from Eric's comments, you may find it a good idea to cast the
>expression sizeof(char) * CHAR_BIT to unsigned long before passing it to a
>variadic function such as printf.


Or, more generally, to the actual type expected by the respective
conversion description.

Unless you're using a conforming C99 implementation, there is no
conversion description that is guarantee to properly handle a size_t
value. Even worse, in the case of sizeof(type) * CHAR_BIT, the type
of the expression can be either size_t or int.


...or unsigned int.


ONLY if size_t is an alias of unsigned int (or a shorter unsigned type
with identical properties).

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #26
In <3F***********@ earthlink.net> Joe Wright <jo********@ear thlink.net> writes:
Dan Pop wrote:

In <3F***********@ earthlink.net> Joe Wright <jo********@ear thlink.net> writes:
>Try this.
>
>/*
> Sizes of various things in bits..
>*/
>#include <stdio.h>
>#include <limits.h>
>
>int main(void) {
> unsigned int a, b, c;
> unsigned long long x, y, z;
>
> c = -1;
> b = 1 << (sizeof(int)*CH AR_BIT-1);
> a = ~b;
>
> z = -1;
> y = 1LL << (sizeof(long long)*CHAR_BIT-1);
> x = ~y;
>
> printf("Size of void = %2lu bits\n", sizeof(void) *
>CHAR_BIT);
> printf("Size of char = %2lu bits\n", sizeof(char) *
>CHAR_BIT);
> printf("Size of short = %2lu bits\n", sizeof(short) *
>CHAR_BIT);
> printf("Size of int = %2lu bits\n", sizeof(int) *
>CHAR_BIT);
> printf("Size of long = %2lu bits\n", sizeof(long) *
>CHAR_BIT);
> printf("Size of long long = %2lu bits\n", sizeof(long long) *
>CHAR_BIT);
> printf("Size of int * = %2lu bits\n", sizeof(int *) *
>CHAR_BIT);
> printf("Size of char * = %2lu bits\n", sizeof(char *) *
>CHAR_BIT);
> printf("Size of void * = %2lu bits\n", sizeof(void *) *
>CHAR_BIT);
> printf("Size of float = %2lu bits\n", sizeof(float) *
>CHAR_BIT);
> printf("Size of double = %2lu bits\n", sizeof(double) *
>CHAR_BIT);
> printf("Size of long double = %2lu bits\n", sizeof(long double) *
>CHAR_BIT);
> printf("Max int = %11d\n", a);
> printf("Min int = %11d\n", b);
> printf("Max unsigned int = %11u\n", c);
> printf("Max long long = %20lld\n", x);
> printf("Min long long = %20lld\n", y);
> printf("Max unsigned long long = %20llu\n", z);
> return 0;
>}
Try it yourself, with the compiler in conforming mode, this time!

Come on Dan, lighten up. As you have noted elsethread, we are not likely
to have C99 conformance. Vanilla gcc compiles this fine.


Vanilla gcc doesn't compile C, and this is NOT a gratuitously pedantic
remark.
With -ansi
-pedantic it complains about 'long long' of course. I've already
forgotten why I felt compelled to post code here.


Even with -std=c99 -pedantic your code fails to compile cleanly, because
of sizeof(void) which is nonsense in C: void is an incomplete type.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #27
Da*****@cern.ch (Dan Pop) wrote in message news:<bp******* ****@sunnews.ce rn.ch>...
In <63************ **************@ posting.google. com> ai***@acay.com. au (Peter Nilsson) writes:
Da*****@cern.c h (Dan Pop) wrote in message news:<bo******* ***@sunnews.cer n.ch>...
In <bo**********@s parta.btinterne t.com> Richard Heathfield <do******@addre ss.co.uk.invali d> writes:
> <snip>
>Apart from Eric's comments, you may find it a good idea to cast the
>expression sizeof(char) * CHAR_BIT to unsigned long before passing it to a
>variadic function such as printf.

Or, more generally, to the actual type expected by the respective
conversion description.

Unless you're using a conforming C99 implementation, there is no
conversion description that is guarantee to properly handle a size_t
value. Even worse, in the case of sizeof(type) * CHAR_BIT, the type
of the expression can be either size_t or int.


...or unsigned int.


ONLY if size_t is an alias of unsigned int (or a shorter unsigned type
with identical properties).


What properties would need to be identical?

--
Peter
Nov 13 '05 #28
Dan Pop wrote:

In <3F***********@ earthlink.net> Joe Wright <jo********@ear thlink.net> writes:
Dan Pop wrote:

In <3F***********@ earthlink.net> Joe Wright <jo********@ear thlink.net> writes:

>Try this.
> [ code snipped ]
Try it yourself, with the compiler in conforming mode, this time!

Come on Dan, lighten up. As you have noted elsethread, we are not likely
to have C99 conformance. Vanilla gcc compiles this fine.


Vanilla gcc doesn't compile C, and this is NOT a gratuitously pedantic
remark.
With -ansi
-pedantic it complains about 'long long' of course. I've already
forgotten why I felt compelled to post code here.


Even with -std=c99 -pedantic your code fails to compile cleanly, because
of sizeof(void) which is nonsense in C: void is an incomplete type.

You are completely right. I shouldn't ask you to lighten up on me. I
made at least four 'mistakes' in that code and you came down hard on two
of them. Thank you. I need to be more careful in what I write and what I
post.

I promise to be more careful in the future. Please keep trying to catch
me out.

Thanks.
--
Joe Wright http://www.jw-wright.com
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 13 '05 #29
In <63************ **************@ posting.google. com> ai***@acay.com. au (Peter Nilsson) writes:
Da*****@cern.c h (Dan Pop) wrote in message news:<bp******* ****@sunnews.ce rn.ch>...
In <63************ **************@ posting.google. com> ai***@acay.com. au (Peter Nilsson) writes:
>Da*****@cern.c h (Dan Pop) wrote in message news:<bo******* ***@sunnews.cer n.ch>...
>> In <bo**********@s parta.btinterne t.com> Richard Heathfield <do******@addre ss.co.uk.invali d> writes:
>> > <snip>
>> >Apart from Eric's comments, you may find it a good idea to cast the
>> >expression sizeof(char) * CHAR_BIT to unsigned long before passing it to a
>> >variadic function such as printf.
>>
>> Or, more generally, to the actual type expected by the respective
>> conversion description.
>>
>> Unless you're using a conforming C99 implementation, there is no
>> conversion description that is guarantee to properly handle a size_t
>> value. Even worse, in the case of sizeof(type) * CHAR_BIT, the type
>> of the expression can be either size_t or int.
>
>...or unsigned int.


ONLY if size_t is an alias of unsigned int (or a shorter unsigned type
with identical properties).


What properties would need to be identical?


The range.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #30

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

Similar topics

1
6908
by: George Marsaglia | last post by:
The essence of a multiply-with-carry RNG is to have declarations in the RNG proc, such as unsigned long mwc( ){ static unsigned long x = 123456789, c = 362436; unsigned long long t, a = 916905990LL; \* then reatedly form the 64-bit t = a*x+c, after which the new carry c is the top 32, and the new x (output), is the bottom 32 bits of t:
1
3004
by: Sushil | last post by:
hi Gurus I'm a newbie learning C. I've a question, relevant code snippet is as follows : typedef unsigned long long ulonglong; struct foo { unsigned dummy : 2; unsigned n : 24;
12
5454
by: Peter Ammon | last post by:
When I add an unsigned long long and an int, what type do each of the values get promoted to before the addition is performed? What is the type of the resulting expression? What occurs if the addition overflows or underflows? Thanks, -Peter
36
5316
by: Digital Puer | last post by:
Hi, suppose I have an unsigned long long. I would like to extract the front 'n' bits of this value and convert them into an integer. For example, if I extract the first 3 bits, I would get an int between 0 and 7 (=2^3-1). Could someone please help out? I can assume the largest returned value fits in an int. Also, I'm on a big-endian PPC (AIX), in case that matters. Ideally, I'd like to implement a prototype like: int...
9
3952
by: luke | last post by:
Hi everybody, please, can someone explain me this behaviour. I have the following piece of code: long long ll; unsigned int i = 2; ll = -1 * i; printf("%lld\n", ll);
3
13184
by: Nicholas Zhou | last post by:
Hi, I was writing a testing program to test the ranges of char, short, int and long variables on my computer, both signed and unsigned. Everything was fine except for unsigned int and unsigned long. I got 0 to -1 for both. The expected answers should be: unsigned int: 0 to 65535 unsigned long: 0 to 4294967295
9
6425
by: vadivel.ks | last post by:
hi, My code having unsigned long long int64_t; like that.. compile error message is long followed by long is illegal, what is the reason for it?
21
2650
by: Bart C | last post by:
I've always had a problem knowing exactly how wide my integer variables were in C, and the little program below has increased my confusion. Run on 3 compilers on the same cpu (32-bit pentium), sometimes int and long int are the same, and long long int is twice the width; or sometimes both long int and long long int are twice the width of int. This apparently all quite normal according to my c99 draft and c-faq.com. However it doesn't...
17
7561
by: Tarique | last post by:
This program was compiled on MS Visual C++ 08 /*Fibonacci Numbers*/ #include<stdio.h> #include<limits.h> void fibonacci(int n) { unsigned long long fib0 = 0; /*First Fibonacci Number*/
0
9554
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9988
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9923
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7358
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6640
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5266
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3911
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 we have to send another system
3
2788
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.