Velocity Reviews > Re: Unsigned Integer Overflow on Multiplication and Division

# Re: Unsigned Integer Overflow on Multiplication and Division

Eric Sosman
Guest
Posts: n/a

 05-13-2010
On 5/13/2010 3:52 PM, Datesfat Chicks wrote:
> What do the standards say about when you multiply two unsigned integers
> and the result is too big?
>
>
> Is the compiler required to give you the actual result modulo 2^32 or
> 2^64, or is the behavior pretty much undefined?

--
Eric Sosman
http://www.velocityreviews.com/forums/(E-Mail Removed)lid

Eric Sosman
Guest
Posts: n/a

 05-13-2010
On 5/13/2010 4:07 PM, Datesfat Chicks wrote:
> "Eric Sosman" <(E-Mail Removed)> wrote in message
> news:hshlhg\$cdb\$(E-Mail Removed)-september.org...
>> On 5/13/2010 3:52 PM, Datesfat Chicks wrote:
>>> What do the standards say about when you multiply two unsigned integers
>>> and the result is too big?
>>>
>>>
>>> Is the compiler required to give you the actual result modulo 2^32 or
>>> 2^64, or is the behavior pretty much undefined?

>>
>> What does your textbook say?

>
> Thanks for the humor, but this is not a homework problem.

No implication of homework intended. Still: What does your
textbook say? If you are such a C newbie that you need to ask so
basic a question, you *need* a textbook. Really, truly. Get one.

(Odd that someone unversed in the use of unsigned arithmetic

> I'm implementing a pseudo-random number generator using a
> microcontroller C compiler, and (as I'm sure you know) arithmetic modulo
> 2^32 is what I'm looking for.
>
> I know what the library that comes with the compiler will do (it is
> fairly obvious on a microcontroller because of the instruction set), but
> I'm just curious if that is required behavior or coincidentally
> convenient behavior.

no sense, try posting a confusing passage or two (and mention what
textbook they come from).

--
Eric Sosman
(E-Mail Removed)lid