long long integer and double precision number
Author |
Message |
cyberdud #1 / 15
|
long long integer and double precision number
Hi, I can declare a variable as a long long integer in my program. It is a 4 byte integer. A double precision variable also has 4 bytes. Does it that the maximum and minimum values that a long long integer and a double precision number can represent are essentially the same? If the maximum and minimum values they can hold are the same, then what are their differences? David
|
Fri, 09 Dec 2005 10:08:42 GMT |
|
|
Martien Verbrugge #2 / 15
|
long long integer and double precision number
On Mon, 23 Jun 2003 02:08:42 +0000 (UTC),
Quote: > Hi, > I can declare a variable as a long long integer in my program. It is a 4 > byte integer.
That's interesting. A long long (assuming your compiler follows the C99 standard on this) is supposed to have at least 64 bits (or rather, a range from -(2^63 - 1) to 2^63 - 1. That would mean that a byte on your platform would need to be at least 16 bits. This isn't impossible, but it is a bit unusual. What's the value of CHAR_BIT? Quote: > A double precision variable also has 4 bytes. Does it that > the maximum and minimum values that a long long integer and a double > precision number can represent are essentially the same?
Euhm... No. Doubles store double precision floats, long long integer store integers. Very different beasts. The fact that your double is also 4 bytes seems to indicate indeed that your CHAR_BIT is larger than 8. It makes almost no sense to compare the range of long long integers and doubles. They are simply defined in a very different manner. Quote: > If the maximum > and minimum values they can hold are the same, then what are their > differences?
A double can store many values that an integer cannot store. Many values between 0 and 1, for example. A double is a floating point type, and can be used to store floating point numbers. A long long integer is an integer type, and can store only integers. Martien -- | Martien Verbruggen | I'm just very selective about what I accept Trading Post Australia | as reality - Calvin |
|
Fri, 09 Dec 2005 10:59:44 GMT |
|
|
Gordon Burdi #3 / 15
|
long long integer and double precision number
Quote: >I can declare a variable as a long long integer in my program. It is a 4 >byte integer.
What size are the bytes on your system? long long is generally AT LEAST a 64-bit integer, where it is implemented. Quote: >A double precision variable also has 4 bytes. Does it that
What size are the bytes on your system? An IEEE double-precision floating-point number has 64 bits. Quote: >the maximum and minimum values that a long long integer and a double >precision number can represent are essentially the same?
No. An IEEE double (C is NOT required to use IEEE floating point, but it's allowed) has a maximum value somewhat higher than 10**308, which is MUCH, MUCH higher than (2**63)-1. (** is an exponentiation operator for the purpose of representing math in this post, and in fortran, but it is NOT valid in C). Quote: >If the maximum >and minimum values they can hold are the same, then what are their >differences?
Integers can only represent integers. Floating-point numbers can represent fractions as well. Gordon L. Burditt
|
Fri, 09 Dec 2005 11:10:20 GMT |
|
|
cyberdud #4 / 15
|
long long integer and double precision number
Hi, Sorry that I was wrong. I am programming on a platform where 1 byte=8 bits. A long long integer in my C program has actually 8 bytes and that means it has 64 bits. A double precision number, as you and the other one who gave me a reply reminded me, has 64 bits. By the way, what is CHAT_BIT? David Quote: > On Mon, 23 Jun 2003 02:08:42 +0000 (UTC),
>> Hi, >> I can declare a variable as a long long integer in my program. It is a 4 >> byte integer. > That's interesting. A long long (assuming your compiler follows the > C99 standard on this) is supposed to have at least 64 bits (or rather, > a range from -(2^63 - 1) to 2^63 - 1. That would mean that a byte on > your platform would need to be at least 16 bits. This isn't > impossible, but it is a bit unusual. What's the value of CHAR_BIT? >> A double precision variable also has 4 bytes. Does it that >> the maximum and minimum values that a long long integer and a double >> precision number can represent are essentially the same? > Euhm... No. Doubles store double precision floats, long long integer > store integers. Very different beasts. The fact that your double is > also 4 bytes seems to indicate indeed that your CHAR_BIT is larger > than 8. It makes almost no sense to compare the range of long long > integers and doubles. They are simply defined in a very different > manner. >> If the maximum >> and minimum values they can hold are the same, then what are their >> differences? > A double can store many values that an integer cannot store. Many > values between 0 and 1, for example. A double is a floating point > type, and can be used to store floating point numbers. A long long > integer is an integer type, and can store only integers. > Martien > -- > | > Martien Verbruggen | I'm just very selective about what I accept > Trading Post Australia | as reality - Calvin > |
|
Fri, 09 Dec 2005 12:31:47 GMT |
|
|
Gordon Burdi #5 / 15
|
long long integer and double precision number
Quote: >Sorry that I was wrong. I am programming on a platform where 1 byte=8 >bits. A long long integer in my C program has actually 8 bytes and that >means it has 64 bits. A double precision number, as you and the other one >who gave me a reply reminded me, has 64 bits. By the way, what is >CHAT_BIT?
CHAR_BIT is the number of bits in a C character (or byte: the standard defines these as the same thing), defined in <limits.h>. It is NOT required to be 8, but that is a very common value. (It is required to be AT LEAST 8). It might be 16 on PC hardware on a system using a 16-bit character set. CHAT_BIT is a disease you get from spending too much time using IRC without using a {*filter*}. Gordon L. Burditt
|
Fri, 09 Dec 2005 15:32:17 GMT |
|
|
Martien Verbrugge #6 / 15
|
long long integer and double precision number
[Please, don't top-post] On Mon, 23 Jun 2003 04:31:47 +0000 (UTC),
Quote:
>> On Mon, 23 Jun 2003 02:08:42 +0000 (UTC),
>>> Hi, >>> I can declare a variable as a long long integer in my program. It is a 4 >>> byte integer. >> That's interesting. A long long (assuming your compiler follows the >> C99 standard on this) is supposed to have at least 64 bits (or rather, >> a range from -(2^63 - 1) to 2^63 - 1. That would mean that a byte on >> your platform would need to be at least 16 bits. This isn't >> impossible, but it is a bit unusual. What's the value of CHAR_BIT? > Sorry that I was wrong. I am programming on a platform where 1 byte=8 > bits. A long long integer in my C program has actually 8 bytes and that > means it has 64 bits. A double precision number, as you and the other one > who gave me a reply reminded me, has 64 bits. By the way, what is > CHAT_BIT?
CHAR_BIT. It's a constant defined in limits.h, giving you the number of bits in a byte (char) for your implementation. That same limits.h also defines all the upper and lower limits on your integer types (CHAR_MIN and CHAR_MAX, INT_MIN, INT_MAX, LLONG_MIN, LLONG_MAX, and many others), as well as the various parameters that define precision and range of the floating point types. Martien -- | Martien Verbruggen | Trading Post Australia | 42.6% of statistics is made up on the spot. |
|
Sat, 10 Dec 2005 08:07:18 GMT |
|
|
cyberdud #7 / 15
|
long long integer and double precision number
Hi, Thanks for telling me about CHAR_BIT. But it seems I needn't to put limits.h in my C programs. Actually, where can I find this file? Thank you in advance. David Quote: > CHAR_BIT. > It's a constant defined in limits.h, giving you the number of bits in > a byte (char) for your implementation. > That same limits.h also defines all the upper and lower limits on your > integer types (CHAR_MIN and CHAR_MAX, INT_MIN, INT_MAX, LLONG_MIN, > LLONG_MAX, and many others), as well as the various parameters that > define precision and range of the floating point types. > Martien > -- > | > Martien Verbruggen | > Trading Post Australia | 42.6% of statistics is made up on the spot. > |
|
Sat, 10 Dec 2005 09:38:50 GMT |
|
|
Jack Klei #8 / 15
|
long long integer and double precision number
On Tue, 24 Jun 2003 01:38:50 +0000 (UTC), {*filter*}dude
Please don't top post. New material you add belongs _after_ quoted material you are replying to. I reformatted this post and added my answer after your question, where it belongs. Quote:
> > CHAR_BIT. > > It's a constant defined in limits.h, giving you the number of bits in > > a byte (char) for your implementation. > > That same limits.h also defines all the upper and lower limits on your > > integer types (CHAR_MIN and CHAR_MAX, INT_MIN, INT_MAX, LLONG_MIN, > > LLONG_MAX, and many others), as well as the various parameters that > > define precision and range of the floating point types. > > Martien > Hi, > Thanks for telling me about CHAR_BIT. But it seems I needn't to put > limits.h in my C programs. Actually, where can I find this file? Thank > you in advance. > David
limits.h should be in the same place all other the headers that came with your compiler live, like stdio.h and string.h. It is a standard C header and every comforting compiler since at least 1989 provides it. -- Jack Klein Home: http://www.*-*-*.com/ FAQs for comp.lang.c http://www.*-*-*.com/ ~scs/C-faq/top.html comp.lang.c++ http://www.*-*-*.com/ ++-faq-lite/ alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
|
Sat, 10 Dec 2005 11:32:41 GMT |
|
|
CBFalcone #9 / 15
|
long long integer and double precision number
*** Rude topposting repaired *** Quote:
> > CHAR_BIT. > > It's a constant defined in limits.h, giving you the number of > > bits in a byte (char) for your implementation. > > That same limits.h also defines all the upper and lower limits > > on your integer types (CHAR_MIN and CHAR_MAX, INT_MIN, INT_MAX, > > LLONG_MIN, LLONG_MAX, and many others), as well as the various > > parameters that define precision and range of the floating > > point types. > Thanks for telling me about CHAR_BIT. But it seems I needn't to > put limits.h in my C programs. Actually, where can I find this > file? Thank you in advance.
You simple add the statement "#include <limits.h>" in your program, just like any other header file. It is a part of standard C. While there may be an actual file, there is no requirement for your system to have such. What the include statement defines is specified in the C standard. Please do not toppost in future. --
Available for consulting/temporary embedded and systems. <http://cbfalconer.home.att.net> USE worldnet address!
|
Sat, 10 Dec 2005 11:40:35 GMT |
|
|
Morris Dove #10 / 15
|
long long integer and double precision number
> It is a standard C header and every comforting compiler since > at least 1989 provides it. ^^^^^^^^^^^^^^^^^^^ OMG! I can't tell you how long I've been wanting one of these - where can I get one? -- Morris Dovey West Des Moines, Iowa USA C links at http://www.iedu.com/c
|
Sat, 10 Dec 2005 11:43:38 GMT |
|
|
Clint Olse #11 / 15
|
long long integer and double precision number
Quote:
> OMG! I can't tell you how long I've been wanting one of these - where can > I get one?
Damn, I was too slow... :) -Clint
|
Sat, 10 Dec 2005 12:19:23 GMT |
|
|
Dan P #12 / 15
|
long long integer and double precision number
Quote: >You simple add the statement "#include <limits.h>" in your >program, just like any other header file.
#include is NOT a statement, it is a preprocessing directive. Correct terminology is important in a newsgroup supposed to educate the beginners. Dan -- Dan Pop DESY Zeuthen, RZ group
|
Sat, 10 Dec 2005 20:11:16 GMT |
|
|
cyberdud #13 / 15
|
long long integer and double precision number
Hi, Sorry for my act. But what is toppost? It seems there are more rules I have to follow in order to post in this news group. :) David Quote: > On Tue, 24 Jun 2003 01:38:50 +0000 (UTC), {*filter*}dude
> Please don't top post. New material you add belongs _after_ quoted > material you are replying to. I reformatted this post and added my > answer after your question, where it belongs.
>> > CHAR_BIT. >> > It's a constant defined in limits.h, giving you the number of bits in >> > a byte (char) for your implementation. >> > That same limits.h also defines all the upper and lower limits on your >> > integer types (CHAR_MIN and CHAR_MAX, INT_MIN, INT_MAX, LLONG_MIN, >> > LLONG_MAX, and many others), as well as the various parameters that >> > define precision and range of the floating point types. >> > Martien >> Hi, >> Thanks for telling me about CHAR_BIT. But it seems I needn't to put >> limits.h in my C programs. Actually, where can I find this file? Thank >> you in advance. >> David > limits.h should be in the same place all other the headers that came > with your compiler live, like stdio.h and string.h. It is a standard > C header and every comforting compiler since at least 1989 provides > it. > -- > Jack Klein > Home: http://www.*-*-*.com/ > FAQs for > comp.lang.c http://www.*-*-*.com/ ~scs/C-faq/top.html > comp.lang.c++ http://www.*-*-*.com/ ++-faq-lite/ > alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
|
Sat, 10 Dec 2005 20:30:52 GMT |
|
|
dbti #14 / 15
|
long long integer and double precision number
On Tue, 24 Jun 2003 12:30:52 +0000 (UTC), {*filter*}dude
This is top posting (posting replies BEFORE the message to which you are replying). Now scroll down to the end of the message. Quote:
> Hi, > Sorry for my act. But what is toppost? > It seems there are more rules I have to follow in order to post in this > news group. :) > David >> On Tue, 24 Jun 2003 01:38:50 +0000 (UTC), {*filter*}dude
>> Please don't top post. New material you add belongs _after_ quoted >> material you are replying to. I reformatted this post and added my >> answer after your question, where it belongs.
>>> > CHAR_BIT. >>> > It's a constant defined in limits.h, giving you the number of bits in >>> > a byte (char) for your implementation. >>> > That same limits.h also defines all the upper and lower limits on >>> your >>> > integer types (CHAR_MIN and CHAR_MAX, INT_MIN, INT_MAX, LLONG_MIN, >>> > LLONG_MAX, and many others), as well as the various parameters that >>> > define precision and range of the floating point types. >>> > Martien >>> Hi, >>> Thanks for telling me about CHAR_BIT. But it seems I needn't to put >>> limits.h in my C programs. Actually, where can I find this file? >>> Thank >>> you in advance. >>> David >> limits.h should be in the same place all other the headers that came >> with your compiler live, like stdio.h and string.h. It is a standard >> C header and every comforting compiler since at least 1989 provides >> it. >> -- Jack Klein >> Home: http://www.*-*-*.com/ >> FAQs for >> comp.lang.c http://www.*-*-*.com/ ~scs/C-faq/top.html >> comp.lang.c++ http://www.*-*-*.com/ ++-faq-lite/ >> alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
This is where people in comp.lang.c (and the rest of Usenet, pretty much) like to see responses.
|
Sat, 10 Dec 2005 22:59:31 GMT |
|
|
Keith Thompso #15 / 15
|
long long integer and double precision number
Quote:
> Sorry for my act. But what is toppost? > It seems there are more rules I have to follow in order to post in this > news group. :)
Allow me to demonstrate. ======================================== A: No. Quote: > Q: Should my response precede what I'm responding to?
======================================== The convention in this newsgroup, and in most others, is to write your responses *after* the quoted material to which you're responding. It's also unnecessary to quote the entire article to which you're responding; just provide enough context for your answer to make sense. Remember that most of your readers have already read the previous article; they don't need to see the whole thing again. This convention allows readers to read each article from beginning to end, without having to go back and forth to pick up any relevant context. There's a competing convention in which the entire previous article is quoted, including all the previous responses which it quoted, with the new material at the top. This leads to huge articles consisting mostly of lines starting with "> > > > > > "; these lines are either too long for most readers' displays, or are broken arbitrarily to make them fit. Each article is a then copy of the entire thread, with earlier part of reformatted to make them more difficult to read. Putting the new material at the top does make it easier to see, but only because the bulk of the article consists of wasteful junk which most readers will ignore anyway. In my opinion, the only thing worse than this convention is a mixture of the two. That's why a lot of us will rearrange top-posted articles when we respond to them. Unfortunately, a lot of news and e-mail software makes this latter convention easier to use; it automatically quotes the entire previous article and leaves the cursor (insertion point) at the beginning of the quoted material. It takes a little extra effort to trim the quoted material and place your responses after it, but you only have to do it once, and it benefits the hundreds or thousands of people who are going to read your article. Most of us here take the time to do this for your benefit (and each other's). We tend to be pickier here than than the denizens of most other newsgroups because this is a very high-volume technical group that's in constant danger of being overwhelmed by inappropriate material. --
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst> Schroedinger does Shakespeare: "To be *and* not to be"
|
Mon, 12 Dec 2005 03:54:03 GMT |
|
|
|