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

What's wrong with long long?

I use long longs occasionally. I know there are some limitations regarding
the standards such as not using long long constants but what's the big
deal? Why is long long not used so much?

Mike
Nov 14 '05 #1
24 1828
Michael B Allen wrote:
I use long longs occasionally. I know there are some limitations regarding
the standards such as not using long long constants but what's the big
deal? Why is long long not used so much?

Mike


I've played with long long but I don't remember using it in a
program. I'm sure that if programming problem arises that requires
integers larger than +-2 or +4 billion, I will use long long quite
naturally.
--
Joe Wright mailto:jo********@comcast.net
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 14 '05 #2

"Michael B Allen" <mb*****@ioplex.com> wrote in message
news:pa********************************@ioplex.com ...
I use long longs occasionally. I know there are some limitations regarding
the standards such as not using long long constants but what's the big
deal? Why is long long not used so much?

Some people are still using Microsoft compilers which reject long long.
Apparently, MS are using macros such as ULONG64 in some of their headers.
I've asked some of their fans about the rationale for this, and got total
silence as an answer. long long appears to have reached full citizenship in
the recent round of MS road shows.
I have a version of their compiler which does support long long, and yet is
to be obsoleted at the end of the year, along with those which don't. Are
you implying that none of the Microsoft compilers support long long
constants? It's true that MS compilers may not take long constants as long
long.
Would you care to bet on the likelihood of people who still claim that long
long isn't standard changing their mind 6 months from now when MS stops
"supporting" compilers which reject it?
Nov 14 '05 #3

"Michael B Allen" <mb*****@ioplex.com> wrote in message

Why is long long not used so much?

A number must ultimately represent something in the real world. You seldom
need a number above 4 billion, which is about the number of adults in the
world. An exception is memory size, which can exceed 4GB on large systems
and may soon be around that on desktop PCs, but in C we use size_t for
amounts of memory.
Nov 14 '05 #4

"Malcolm" <ma*****@55bank.freeserve.co.uk> wrote in message
news:ca**********@news6.svr.pol.co.uk...

"Michael B Allen" <mb*****@ioplex.com> wrote in message

Why is long long not used so much?

A number must ultimately represent something in the real world. You seldom
need a number above 4 billion, which is about the number of adults in the
world. An exception is memory size, which can exceed 4GB on large systems
and may soon be around that on desktop PCs, but in C we use size_t for
amounts of memory.

This will change soon as we move to IPv6. Networking will be one
application where >32bit numbers are required.

Dan
Nov 14 '05 #5
"Dan P." <dp***************@ec.rr.com> writes:
"Malcolm" <ma*****@55bank.freeserve.co.uk> wrote in message
news:ca**********@news6.svr.pol.co.uk...

"Michael B Allen" <mb*****@ioplex.com> wrote in message

Why is long long not used so much?

A number must ultimately represent something in the real world. You seldom
need a number above 4 billion, which is about the number of adults in the
world. An exception is memory size, which can exceed 4GB on large systems
and may soon be around that on desktop PCs, but in C we use size_t for
amounts of memory.

This will change soon as we move to IPv6. Networking will be one
application where >32bit numbers are required.


An IPv6 address is 128 bits, but I don't think it's typically
represented as a single number. I don't know of any systems that
directly support 128-bit integers anyway. (Counterexamples would not
contradict my main point.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #6
Keith Thompson wrote:
"Dan P." <dp***************@ec.rr.com> writes:

.... snip ...

This will change soon as we move to IPv6. Networking will be
one application where >32bit numbers are required.


An IPv6 address is 128 bits, but I don't think it's typically
represented as a single number. I don't know of any systems
that directly support 128-bit integers anyway. (Counterexamples
would not contradict my main point.)


That should last throught the first Galactic Empire and the fall
of Trantor :-)

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!

Nov 14 '05 #7
On Sun, 13 Jun 2004 15:05:48 +0100, "Malcolm"
<ma*****@55bank.freeserve.co.uk> wrote in comp.lang.c:

"Michael B Allen" <mb*****@ioplex.com> wrote in message

Why is long long not used so much?

A number must ultimately represent something in the real world. You seldom
need a number above 4 billion, which is about the number of adults in the
world. An exception is memory size, which can exceed 4GB on large systems
and may soon be around that on desktop PCs, but in C we use size_t for
amounts of memory.


What an absurd line of reasoning. Are you actually this clueless, or
just trolling?

On a heavy trading day on the US stock exchanges, the number of shares
traded on the NASDAQ exchange can exceed the maximum value of a signed
32-bit long int.

I seem to recall, but can't be bothered to look up, that there have
been days when the sum of shares traded on the AMEX and NASDAQ
exchanges exceeded the maximum value of an unsigned 32-bit long.

Not to mention the fact that a large number of simple mathematical and
statistical algorithms, often most efficiently implemented with
integer math, require raising numbers to the second power. The range
of the second power of numbers that fit in a 32-bit integer type most
certainly will not fit in anything less than a 64-bit integer type.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #8
In article <s0********************************@4ax.com>,
Jack Klein <ja*******@spamcop.net> wrote:
Not to mention the fact that a large number of simple mathematical and
statistical algorithms, often most efficiently implemented with
integer math, require raising numbers to the second power. The range
of the second power of numbers that fit in a 32-bit integer type most
certainly will not fit in anything less than a 64-bit integer type.


I think in one of Donald Knuth's book there was a trick question: What
is the fastest algorithm to calculate n raised to the 19th power? The
answer was: Since the result must fit into n bits, the argument can be
at most (some tiny number), so the fastest method is a lookup-table...
Nov 14 '05 #9

"Jack Klein" <ja*******@spamcop.net> wrote in message
On Sun, 13 Jun 2004 15:05:48 +0100, "Malcolm"
<ma*****@55bank.freeserve.co.uk> wrote in comp.lang.c:
What an absurd line of reasoning. Are you actually this clueless, > or just trolling?
On a heavy trading day on the US stock exchanges,

So you've come up with another exception. No-one is claiming that never ever
will you need a number over 4 billion. Clearly, if you need to give an id
number to the entire population of the world, or you need to tag every US
cent in circulation, or you are doing some fancy statistical work that
generates large integers, then these are exceptions. However the exceptions
don't arise very often, which is why you will seldom see long long used in
real programs.
Nov 14 '05 #10
>> What an absurd line of reasoning. Are you actually this clueless, > or
just trolling?

On a heavy trading day on the US stock exchanges,

So you've come up with another exception. No-one is claiming that never ever
will you need a number over 4 billion. Clearly, if you need to give an id
number to the entire population of the world, or you need to tag every US
cent in circulation, or you are doing some fancy statistical work that
generates large integers, then these are exceptions. However the exceptions
don't arise very often, which is why you will seldom see long long used in
real programs.


It doesn't take big finances to come up with numbers to overflow a
32-bit integer.

Dollar amounts are best represented as integer quantities of cents,
(assuming you are using integers at all, and you're using dollars),
since accountants like the books to balance exactly. It is often
necessary to use signed numbers for accounting purposes (revenue
and expense, profit and loss). Now you're down to a range of +/-
$20 million. Gas stations, which traditionally have prices ending
in "and nine-tenths of a cent per gallon" might be using integer
quantities of tenths of a cent.

A grocery store (a SINGLE STORE, not a chain) with 10 employees
earning $30,000 annual salary average and margins of 1% (profit
margins tend to be thin in the grocery business) needs to have
revenue of $30 million/year just to support the employees (which
overflows). That money tends to show up on the books multiple times
(e.g. sales of products and purchases of products from vendors).
As grocery stores go, one with only 10 employees is a lot smaller
than most of the ones around here.

Lifetime earnings of some individual higher-paid people (such as
top executives and major-league baseball players) of over $500,000
per year over 40 years would exceed the +/- $20 million limit.

Further, intermediate results often require more range than the
final results do. For example, to calculate sales tax using integer
math, you might multiply by 8,625 and divide by 100,000, then round
(using the peculiar legally-mandated method of rounding for sales
tax, which does not necessarily coincide with any method used by
mathematics.) Suddenly, you overflow this at slightly over $2318,
which isn't even the price of a single good used car. Granted, for
this example, you *CAN* cancel out common factors of 8625 and 100000,
but that 8.625% number is something the state gives you and keeps
changing, and sooner or later they'll give you a prime number. Even
then, you overflow the calculation at something under $300,000.
Gordon L. Burditt
Nov 14 '05 #11
On Sun, 13 Jun 2004 22:47:35 +0100, "Malcolm"
<ma*****@55bank.freeserve.co.uk> wrote in comp.lang.c:

"Jack Klein" <ja*******@spamcop.net> wrote in message
On Sun, 13 Jun 2004 15:05:48 +0100, "Malcolm"
<ma*****@55bank.freeserve.co.uk> wrote in comp.lang.c:
What an absurd line of reasoning. Are you actually this clueless, > or

just trolling?

On a heavy trading day on the US stock exchanges,

So you've come up with another exception. No-one is claiming that never ever
will you need a number over 4 billion. Clearly, if you need to give an id
number to the entire population of the world, or you need to tag every US
cent in circulation, or you are doing some fancy statistical work that
generates large integers, then these are exceptions. However the exceptions
don't arise very often, which is why you will seldom see long long used in
real programs.


You are very foolishly over generalizing from a lack of perceived need
that YOU feel in the programs that YOU write. Not everyone writes
only the types of programs that you do, or have quite such a set of
blinders to other types of code.

And you haven't addressed my second, very real example. It can be
particularly important in real-time calculations to deal with the
relationships not between variables themselves, but the squares of
those variables. And you can't reliably square 32-bit integer
variables without a 64-bit integer type.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #12
On Sun, 13 Jun 2004 22:47:35 +0100, "Malcolm"
<ma*****@55bank.freeserve.co.uk> wrote:

"Jack Klein" <ja*******@spamcop.net> wrote in message
On Sun, 13 Jun 2004 15:05:48 +0100, "Malcolm"
<ma*****@55bank.freeserve.co.uk> wrote in comp.lang.c:
What an absurd line of reasoning. Are you actually this clueless, > or

just trolling?

On a heavy trading day on the US stock exchanges,

So you've come up with another exception. No-one is claiming that never ever
will you need a number over 4 billion. Clearly, if you need to give an id
number to the entire population of the world, or you need to tag every US
cent in circulation, or you are doing some fancy statistical work that
generates large integers, then these are exceptions. However the exceptions
don't arise very often, which is why you will seldom see long long used in
real programs.


There are thousands or millions of real-world exceptions (I've coded
many). You are blind to anything beyond your quite specific endeavors.

--
Sev
Nov 14 '05 #13
CBFalconer <cb********@yahoo.com> wrote:
Keith Thompson wrote:
An IPv6 address is 128 bits, but I don't think it's typically
represented as a single number.


That should last throught the first Galactic Empire and the fall
of Trantor :-)


I think that's kinda the point.

Richard
Nov 14 '05 #14
Malcolm wrote:
"Jack Klein" <ja*******@spamcop.net> wrote in message
On Sun, 13 Jun 2004 15:05:48 +0100, "Malcolm"
<ma*****@55bank.freeserve.co.uk> wrote in comp.lang.c:
What an absurd line of reasoning. Are you actually this clueless, > or


just trolling?
On a heavy trading day on the US stock exchanges,


So you've come up with another exception. No-one is claiming that never ever
will you need a number over 4 billion. Clearly, if you need to give an id
number to the entire population of the world, or you need to tag every US
cent in circulation, or you are doing some fancy statistical work that
generates large integers, then these are exceptions. However the exceptions
don't arise very often, which is why you will seldom see long long used in
real programs.

I first encountered the need to represent numbers larger than those
representable by 32 bit ints about 3 days after leaving university, when
dealing with Turkish Lira.

2,147,483,647 TRL is currently less than £800/$1500, so that's a
reasonably common use I'd say.

Nov 14 '05 #15
In article <pa********************************@ioplex.com>
Michael B Allen <mb*****@ioplex.com> writes:
... Why is long long not used so much?


I am not so sure it is not (used much).

The various BSDs support files larger than 4 gigabytes, on
disks (including RAID) of many terabytes. (The LaCie "Bigger
Disk" holds 1 terabyte and costs about $1k, so if you build
your own RAID out of some number of these, you could easily
put together a 10+ TB "disk". BSD/OS, FreeBSD, NetBSD, etc.,
will generally let you make a single partition on a big drive
and use it to hold one large file. (There have been some problems
when you hit 2147483648 blocks, or even sectors; and this
has limited people "less than 1,099,511,627,776" bytes in
a partition. Some of the BSDs have fixed this for some or
perhaps even all of their drivers. Block and sector numbers
have historically been stored in 32-bit integers though, so
the signedness fixes only take you from 1 TB to 2 TB. You
have to update the driver to handle even-larger units, and
even switch to UFS2 if you want to go past 16 TB.)

(Wind River's VxWorks has a hardcoded 40-bit limit in the modified
DOS-style file system, and of course the DOS-FAT-compatible file
system is inherently limited to 32-bit file sizes, because Microsoft
did not plan ahead. If you want to use the 40-bit file sizes,
though, you do have to use "long long".)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Nov 14 '05 #16

"Carlos" <ab***@spamcop.net> wrote in message

2,147,483,647 TRL is currently less than £800/$1500, so that's > a reasonably common use I'd say.

So four billion times that is 6 trillion dollars. US government spending is
about 1 trillion dollars a year. So 64 bits is just enough to represent any
amount of money you might need, but only by an order of magnitude.
Nov 14 '05 #17
Malcolm wrote:
...
Why is long long not used so much?

A number must ultimately represent something in the real world. You seldom
need a number above 4 billion, which is about the number of adults in the
world. An exception is memory size, which can exceed 4GB on large systems
and may soon be around that on desktop PCs, but in C we use size_t for
amounts of memory.


Sometimes calculating a value from the "real world" requires a [short]
trip into the realm of "unreal". For example, calculating the Euclidean
distance between two point with "read world"s 'unsigned long'
coordinates might easily involve values that extend beyond 'unsigned
long' range.

--
Best regards,
Andrey Tarasevich

Nov 14 '05 #18
Malcolm wrote:
"Carlos" <ab***@spamcop.net> wrote in message
2,147,483,647 TRL is currently less than £800/$1500, so that's a
reasonably common use I'd say.

So four billion times that is 6 trillion dollars. US government
spending is about 1 trillion dollars a year. So 64 bits is just
enough to represent any amount of money you might need, but only by
an order of magnitude.


The US national debt currently exceeds 7e12 dollars.

Jeremy.
Nov 14 '05 #19
On Wed, 16 Jun 2004 04:25:03 +0100, in comp.lang.c , "Malcolm"
<ma*****@55bank.freeserve.co.uk> wrote:

"Carlos" <ab***@spamcop.net> wrote in message

2,147,483,647 TRL is currently less than £800/$1500, so that's > a

reasonably common use I'd say.

So four billion times that is 6 trillion dollars. US government spending is
about 1 trillion dollars a year. So 64 bits is just enough to represent any
amount of money you might need, but only by an order of magnitude.


Governments are not the world's top spenders. One of my clients transacted
over 6Trln Euros last year just on one trading desk in one locale.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 14 '05 #20
In article <ca*******************@news.demon.co.uk> Carlos <ab***@spamcop.net> writes:
....
I first encountered the need to represent numbers larger than those
representable by 32 bit ints about 3 days after leaving university, when
dealing with Turkish Lira.

2,147,483,647 TRL is currently less than £800/$1500, so that's a
reasonably common use I'd say.


Do they really go to the Lira in accounting and whatever? The last time
I was there, the last four digits were zero and cut off on most price
lists.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Nov 14 '05 #21
In <to********************************@4ax.com> Mark McIntyre <ma**********@spamcop.net> writes:
On Wed, 16 Jun 2004 04:25:03 +0100, in comp.lang.c , "Malcolm"
<ma*****@55bank.freeserve.co.uk> wrote:

"Carlos" <ab***@spamcop.net> wrote in message

2,147,483,647 TRL is currently less than £800/$1500, so that's > a

reasonably common use I'd say.

So four billion times that is 6 trillion dollars. US government spending is
about 1 trillion dollars a year. So 64 bits is just enough to represent any
amount of money you might need, but only by an order of magnitude.


Governments are not the world's top spenders. One of my clients transacted
over 6Trln Euros last year just on one trading desk in one locale.


Trillion is no better defined than billion and I have a feeling that
Mark McIntyre is not using the British definition (1e18, i.e. a million
cubed).

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #22
Michael B Allen wrote:

I use long longs occasionally.
I know there are some limitations regarding
the standards such as not using long long constants but what's the big
deal? Why is long long not used so much?


It's not C89.
Nov 14 '05 #23
pete wrote:
Michael B Allen wrote:

I use long longs occasionally.
I know there are some limitations regarding
the standards such as not using long long constants but what's the big
deal? Why is long long not used so much?


It's not C89.


More reason to use them I guess. C99-ish compilers are so easy to come by
there is no reason not to use it.

Tom
Nov 14 '05 #24
In <FW*******************@twister01.bloor.is.net.cabl e.rogers.com> Tom St Denis <to*@securescience.net> writes:
pete wrote:
Michael B Allen wrote:

I use long longs occasionally.
I know there are some limitations regarding
the standards such as not using long long constants but what's the big
deal? Why is long long not used so much?


It's not C89.


More reason to use them I guess. C99-ish compilers are so easy to come by
there is no reason not to use it.


How do you write C99 code that is portable to C99-ish compilers?

The last thing I'd want to use is a compiler that is mostly conforming to
a certain specification.

Yes, I know, no compiler is perfectly conforming, due to the inherent
bugs in an application as complex as a modern compiler, but there is
a whole world of difference between an obscure compiler bug and the
conformance problems of gcc -std=c99 (e.g. some C99 features are available
with subtly different semantics: the semantics of GNU C).

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

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

Similar topics

0
by: Fabster | last post by:
Below is a code part I got somewhere and works fine for retrieving a version from a single file. Now I want to retrieve all .dll, .ocx and ..exe file versions from my harddisk in all directory's. I...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
46
by: Keith K | last post by:
Having developed with VB since 1992, I am now VERY interested in C#. I've written several applications with C# and I do enjoy the language. What C# Needs: There are a few things that I do...
8
by: Midnight Java Junkie | last post by:
Dear Colleagues: I feel that the dumbest questions are those that are never asked. I have been given the opportunity to get into .NET. Our organization has a subscription with Microsoft that...
10
by: Protoman | last post by:
Could you tell me what's wrong with this program, it doesn't compile: #include <iostream> #include <cstdlib> using namespace std; class Everything { public: static Everything* Instance()
31
by: Cesar Rodas | last post by:
Hello to all As far I know the unsigned char just use 1-byte, long 4-bytes... is this right??? Well I have the next code... #include <stdio.h> #include <stdlib.h>
15
by: robert maas, see http://tinyurl.com/uh3t | last post by:
Here's the source: #include <stdio.h> #include <errno.h> main () { char* str = "9999999999"; long long int llin; char* endptr; /* Set by strtoll */ int nch; errno = 0; llin = strtoll(str,...
22
by: davy.zou | last post by:
I found the code for a program that is suppose to be able to work out the sumation of i from 1 to a certain integer n. however, when I implemented to code into Visual C++, it doesn't work. The...
92
by: Heinrich Pumpernickel | last post by:
what does this warning mean ? #include <stdio.h> int main() { long l = 100; printf("l is %li\n", l * 10L);
10
by: questions | last post by:
# include <stdio.h> # include <math.h> int main() { long int x,y; printf("enter an integer\n"); scanf("%d",&x); y=x%pow(10,3);
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.