"Peter Ammon" <peter_ammon@ro cketmail.com> wrote in message[color=blue]
> What's the most negative double value I can get? Is it always
> guaranteed to be -DBL_MAX? If so, why (or rather, where)?
>[/color]
Most floating point formats have a negative flag bit which can be set or
unset. The most natural system is for the maximum and minimum to be of the
same magnitude.
Peter Ammon wrote:[color=blue]
> What's the most negative double value I can get? Is it always
> guaranteed to be -DBL_MAX? If so, why (or rather, where)?
>
> Thanks.
>[/color]
It is DBL_MIN and it is always -DBL_MAX in IEEE-754 compliant systems..
Papadopoulos Giannis wrote:[color=blue]
> Peter Ammon wrote:
>[color=green]
>> What's the most negative double value I can get? Is it always
>> guaranteed to be -DBL_MAX? If so, why (or rather, where)?
>>
>> Thanks.
>>[/color]
>
> It is DBL_MIN and it is always -DBL_MAX in IEEE-754 compliant systems..[/color]
DBL_MIN on my platform is 2.2250738585072 014e-308 which is positive.
Peter Ammon wrote:[color=blue]
> Papadopoulos Giannis wrote:
>[color=green]
>> Peter Ammon wrote:
>>[color=darkred]
>>> What's the most negative double value I can get? Is it always
>>> guaranteed to be -DBL_MAX? If so, why (or rather, where)?
>>>
>>> Thanks.
>>>[/color]
>>
>> It is DBL_MIN and it is always -DBL_MAX in IEEE-754 compliant systems..[/color]
>
>
> DBL_MIN on my platform is 2.2250738585072 014e-308 which is positive.
>[/color]
F**K.....
I should never post again after 02:00 in the morning...
Yes, the most negative value is -DBL_MAX...
The smallest positive is DBL_MIN...
Peter Ammon wrote:[color=blue]
> Papadopoulos Giannis wrote:[color=green]
> > Peter Ammon wrote:
> >[color=darkred]
> >> What's the most negative double value I can get? Is it always
> >> guaranteed to be -DBL_MAX? If so, why (or rather, where)?[/color]
> >
> > It is DBL_MIN and it is always -DBL_MAX in IEEE-754 compliant systems..[/color]
>
> DBL_MIN on my platform is 2.2250738585072 014e-308 which is positive.[/color]
Which is apparently correct. From N869:
[#10] The values given in the following list shall be
replaced by implementation-defined constant expressions with
(positive) values that are less than or equal to those
shown:
-- the difference between 1 and the least value greater
than 1 that is representable in the given floating
point type, b1-p
--
Chuck F (cbfalconer@yah oo.com) (cbfalconer@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address!
In <c132k7$gvp$1@n ews.apple.com> Peter Ammon <peter_ammon@ro cketmail.com> writes:
[color=blue]
>What's the most negative double value I can get? Is it always
>guaranteed to be -DBL_MAX?[/color]
Yes.
[color=blue]
>If so, why (or rather, where)?[/color]
Because the standard uses a sign-magnitude model for the floating point
numbers. 5.2.4.2.2 in C99. Sorry, but the text is next to impossible
to quote in plain text format, without using some special convention,
a la TeX and friends.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Dan.Pop@ifh.de
Christian Bau wrote:[color=blue]
> In article <c13jg2$hit$1@u lysses.noc.ntua .gr>,
> Papadopoulos Giannis <ipapadop@inf.u th.gr> wrote:
>
>[color=green]
>>#include <stdio.h>
>>#define p(s) printf(#s" endian")
>>int main(void){int v=1;*(char*)&v? p(Little):p(Big );return 0;}[/color]
>
>
> You are aware that this is nonsense?
>
> If not, then think about it for five minutes before you respond.[/color]
In article <c15dn0$r78$1@u lysses.noc.ntua .gr>,
Papadopoulos Giannis <ipapadop@inf.u th.gr> wrote:
[color=blue]
> Christian Bau wrote:[color=green]
> > In article <c13jg2$hit$1@u lysses.noc.ntua .gr>,
> > Papadopoulos Giannis <ipapadop@inf.u th.gr> wrote:
> >
> >[color=darkred]
> >>#include <stdio.h>
> >>#define p(s) printf(#s" endian")
> >>int main(void){int v=1;*(char*)&v? p(Little):p(Big );return 0;}[/color]
> >
> >
> > You are aware that this is nonsense?
> >
> > If not, then think about it for five minutes before you respond.[/color]
>
> Please explain...[/color]
Do you think that bigendian and littleendian are the only possibilities?
Could the char that you are reading consist completely of padding bits
in the int, in which case you could get two different results when you
run the program twice?
> > >>#include <stdio.h>[color=blue][color=green][color=darkred]
> > >>#define p(s) printf(#s" endian")
> > >>int main(void){int v=1;*(char*)&v? p(Little):p(Big );return 0;}
> > >
> > >
> > > You are aware that this is nonsense?
> > >
> > > If not, then think about it for five minutes before you respond.[/color]
> >
> > Please explain...[/color]
>
> Do you think that bigendian and littleendian are the only possibilities?
> Could the char that you are reading consist completely of padding bits
> in the int, in which case you could get two different results when you
> run the program twice?[/color]
Do you think that "endianness-detector" is the only possibility
for the purpose of this program? It could in fact be a random
greeting program in Martian, or a pedant-trapper, or a
compiler test, or pretty much anything really.
Christian Bau wrote:[color=blue]
> Do you think that bigendian and littleendian are the only possibilities?[/color]
No, but I believe that are the most common ones..
[color=blue]
> Could the char that you are reading consist completely of padding bits
> in the int, in which case you could get two different results when you
> run the program twice?[/color]
I think if I change *(char*)&v to *(char*)&v==1 I can rid of it.. Or
don't I??
PS If the code below does not work (and I have come across it many
times, in books and the Inet), then what should??
Dan Pop wrote:
[color=blue]
> In <c132k7$gvp$1@n ews.apple.com> Peter Ammon <peter_ammon@ro cketmail.com> writes:
>
>[color=green]
>>What's the most negative double value I can get? Is it always
>>guaranteed to be -DBL_MAX?[/color]
>
>
> Yes.
>
>[color=green]
>>If so, why (or rather, where)?[/color]
>
>
> Because the standard uses a sign-magnitude model for the floating point
> numbers. 5.2.4.2.2 in C99. Sorry, but the text is next to impossible
> to quote in plain text format, without using some special convention,
> a la TeX and friends.
>
> Dan[/color]
In article <c17q21$1rv7$1@ ulysses.noc.ntu a.gr>,
Papadopoulos Giannis <ipapadop@inf.u th.gr> wrote:
[color=blue]
> Christian Bau wrote:[color=green]
> > Do you think that bigendian and littleendian are the only possibilities?[/color]
>
> No, but I believe that are the most common ones..
>[color=green]
> > Could the char that you are reading consist completely of padding bits
> > in the int, in which case you could get two different results when you
> > run the program twice?[/color]
>
> I think if I change *(char*)&v to *(char*)&v==1 I can rid of it.. Or
> don't I??
>
> PS If the code below does not work (and I have come across it many
> times, in books and the Inet), then what should??[/color]
The pragmatic solution is to add an appropriate #define into some header
file. Also helpful is to write code that doesn't depend on endianness in
the first place: For example, to write a value x up to 2^32 to a file,
write the bytes (x >> 24) & 0xff, (x >> 16) & 0xff, (x >> 8) & 0xff, x &
0xff and you will get the same results everywhere.
C doesn't even say that there is such a thing as a "byte ordering": If
for example int has 16 bit, char has 8 bit, and sizeof (int) == 2, then
the 16 bits of an int could be mapped in any possible permutation to the
16 bits in an array of two chars.
In article <843a4f78.04022 10449.204e81aa@ posting.google. com>, oldwolf@inspire .net.nz (Old Wolf) wrote:
[color=blue][color=green][color=darkred]
> > > >>#include <stdio.h>
> > > >>#define p(s) printf(#s" endian")
> > > >>int main(void){int v=1;*(char*)&v? p(Little):p(Big );return 0;}
> > > >
> > > >
> > > > You are aware that this is nonsense?
> > > >
> > > > If not, then think about it for five minutes before you respond.
> > >
> > > Please explain...[/color]
> >
> > Do you think that bigendian and littleendian are the only possibilities?
> > Could the char that you are reading consist completely of padding bits
> > in the int, in which case you could get two different results when you
> > run the program twice?[/color]
>
> Do you think that "endianness-detector" is the only possibility
> for the purpose of this program? It could in fact be a random
> greeting program in Martian, or a pedant-trapper, or a
> compiler test, or pretty much anything really.[/color]
If you read the next reply of the original poster, you will find that it
is an "endianness-detector".
Comment