[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Operation problem

From: Paulo Marques
Subject: Re: [avr-gcc-list] Operation problem
Date: Fri, 10 Aug 2007 12:15:55 +0100
User-agent: Thunderbird (X11/20070509)

Gerard Marull Paretas wrote:


When I try to execute this line:

currentsong.length=(currentsong.frames * currentsong.samples_per_frame) / currentsong.samples_per_sec;

currentsong.length gets no result. However, doing these operations step by step produce the expected results:


The second method requires currentsong.length to be a long int (uint32_t), because the multiplication of currentsong.frames by currentsong.samples_per_frame does not fit on an uint16_t.

I think you just answered your own question: if all the variables involved are uint16_t, then that is the precision used for all he expression and it will overflow on the multiplication.

Paulo Marques
Software Development Department - Grupo PIE, S.A.
Phone: +351 252 290600, Fax: +351 252 290601
Web: www.grupopie.com

"A tautology is a thing which is tautological."

reply via email to

[Prev in Thread] Current Thread [Next in Thread]