|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#26 |
|
Messages: n/a
Hébergeur: |
On Thu, 18 Oct 2007 18:44:05 -0400, pete wrote:
> Richard Heathfield wrote: >> int count_value_bits_in_unsigned_int(void) >> { >> int rv = 0; >> unsigned int n = UINT_MAX; >> while(n > 0) >> { >> ++rv; >> n >>= 1; >> } >> return rv; >> } > > rv should be type unsigned, instead of type int. > The number of value bits in type unsigned isn't > guaranteed to be representable as an int type value. That'd require one unsigned int to occupy at least 4 KB -- Army1987 (Replace "NOSPAM" with "email") A hamburger is better than nothing. Nothing is better than eternal happiness. Therefore, a hamburger is better than eternal happiness. |
|
|
|
#27 |
|
Messages: n/a
Hébergeur: |
On Thu, 18 Oct 2007 18:44:05 -0400, pete wrote:
> The number of value bits in type unsigned isn't > guaranteed to be representable as an int type value. Finding the greatest lower bound for the fraction of padding bits among the bits of int on any implementation where log2(UINT_MAX+1.0) is greater than INT_MAX is left as an exercise to the reader. Now an implementation which wastes more than 99.5% (Hint: unless I had something wrong, this is strictly less than the greatest lower bound) of the bits in an int is an implementation I would rather never have *anything* to do with (including "being to within one light-year of each other"). -- Army1987 (Replace "NOSPAM" with "email") A hamburger is better than nothing. Nothing is better than eternal happiness. Therefore, a hamburger is better than eternal happiness. |
|
|
|
#28 |
|
Messages: n/a
Hébergeur: |
"Army1987" <army1987@NOSPAM.it> a écrit dans le message de news:
pan.2007.10.20.12.47.07.181515@NOSPAM.it... > On Thu, 18 Oct 2007 18:44:05 -0400, pete wrote: > >> Richard Heathfield wrote: >>> int count_value_bits_in_unsigned_int(void) >>> { >>> int rv = 0; >>> unsigned int n = UINT_MAX; >>> while(n > 0) >>> { >>> ++rv; >>> n >>= 1; >>> } >>> return rv; >>> } >> >> rv should be type unsigned, instead of type int. >> The number of value bits in type unsigned isn't >> guaranteed to be representable as an int type value. > That'd require one unsigned int to occupy at least 4 KB And the corresponding int representation to have at least 16368 padding bits ;-) -- Chqrlie. |
|
|
|
#29 |
|
Messages: n/a
Hébergeur: |
On Sat, 20 Oct 2007 15:11:26 +0200, Charlie Gordon wrote:
> "Army1987" <army1987@NOSPAM.it> a écrit dans le message de news: > pan.2007.10.20.12.47.07.181515@NOSPAM.it... >> On Thu, 18 Oct 2007 18:44:05 -0400, pete wrote: >>> rv should be type unsigned, instead of type int. >>> The number of value bits in type unsigned isn't >>> guaranteed to be representable as an int type value. >> That'd require one unsigned int to occupy at least 4 KB > > And the corresponding int representation to have at least 16368 padding bits > ;-) Have you found a way for such an implementation to have less than 32752 padding bits in int? (Yes, "at least 16368" is still true if the greatest lower bound is 32752, but I wander if you found that that lower bound is wrong.) -- Army1987 (Replace "NOSPAM" with "email") A hamburger is better than nothing. Nothing is better than eternal happiness. Therefore, a hamburger is better than eternal happiness. |
|
|
|
#30 |
|
Messages: n/a
Hébergeur: |
"Army1987" <army1987@NOSPAM.it> a écrit dans le message de news:
pan.2007.10.21.08.54.53.234455@NOSPAM.it... > On Sat, 20 Oct 2007 15:11:26 +0200, Charlie Gordon wrote: > >> "Army1987" <army1987@NOSPAM.it> a écrit dans le message de news: >> pan.2007.10.20.12.47.07.181515@NOSPAM.it... >>> On Thu, 18 Oct 2007 18:44:05 -0400, pete wrote: >>>> rv should be type unsigned, instead of type int. >>>> The number of value bits in type unsigned isn't >>>> guaranteed to be representable as an int type value. >>> That'd require one unsigned int to occupy at least 4 KB >> >> And the corresponding int representation to have at least 16368 padding >> bits >> ;-) > > Have you found a way for such an implementation to have less than > 32752 padding bits in int? > (Yes, "at least 16368" is still true if the greatest lower bound > is 32752, but I wander if you found that that lower bound is > wrong.) No, your lower bound seems good. -- Chqrlie. |
|
![]() |
| Outils de la discussion | |
|
|