Re: Implemenation Indepdent Way to Move LSByte of Char to MSB of Int, etc
From: Eric Sosman (esosman_at_acm-dot-org.invalid)
Date: 01/17/05
- Next message: Chris Croughton: "Re: Special C Preprocessing Tool Needed for Pruning of #ifdefs in code"
- Previous message: Old Wolf: "Re: Error E2349 tester.c 29: Nonportable pointer conversion"
- In reply to: bd: "Re: Implemenation Indepdent Way to Move LSByte of Char to MSB of Int, etc"
- Next in thread: Peter Nilsson: "Re: Implemenation Indepdent Way to Move LSByte of Char to MSB of Int, etc"
- Reply: Peter Nilsson: "Re: Implemenation Indepdent Way to Move LSByte of Char to MSB of Int, etc"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 17 Jan 2005 16:49:01 -0500
bd wrote:
> Eric Sosman wrote:
> [...]
>> Maybe there's a way to calculate (UINT_MAX + 1)/(UCHAR_MAX + 1)
>>without risking zero in the numerator and/or denominator, but I
>>haven't figured one out. (Note that UCHAR_MAX == ULLONG_MAX is
>>permitted by the Standard.)
>
> Since UCHAR_MAX <= UINT_MAX <= ULLONG_MAX...
>
> #if UCHAR_MAX == ULLONG_MAX
> # define UINT_UCHAR_RATIO 1
> #else
> # define UINT_UCHAR_RATIO \
> (((unsigned long long)UINT_MAX + 1) / \
> ((unsigned long long)UCHAR_MAX + 1))
> #endif
If UINT_MAX == ULLONG_MAX, this yields a ratio
of zero.
-- Eric Sosman esosman@acm-dot-org.invalid
- Next message: Chris Croughton: "Re: Special C Preprocessing Tool Needed for Pruning of #ifdefs in code"
- Previous message: Old Wolf: "Re: Error E2349 tester.c 29: Nonportable pointer conversion"
- In reply to: bd: "Re: Implemenation Indepdent Way to Move LSByte of Char to MSB of Int, etc"
- Next in thread: Peter Nilsson: "Re: Implemenation Indepdent Way to Move LSByte of Char to MSB of Int, etc"
- Reply: Peter Nilsson: "Re: Implemenation Indepdent Way to Move LSByte of Char to MSB of Int, etc"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]