Sign in

username:

password:



Not a member?

Search motoroladsp



Search tips

Subscribe to motoroladsp



motoroladsp by Keywords

56303 | 563xx | 5680 | 56805 | 5680x | 56F80 | 56F800DEMO | 56F805 | 56f807 | 56F830 | ADC | Bootloader | Codec | CodeWarrior | CW5 | CW6 | Debugger | DSP56303 | DSP56303EVM | DSP563xx | DSP5680 | DSP56800 | DSP56807 | DSP56858 | DSP56858EVM | DSP56F803 | DSP56F805 | DSP56F807 | DSP56F80x | DSP56F826 | DSP56F827 | DSP56F8xx | EVM | FFT | Flash_over_jtag | GPIO | Interrupt | Interrupts | JTAG | LCD | Linker | MCF5307 | Metrowerks | Modulus | MSCAN | PCMaster | PWM | Quad | Rif | RTOS | SDK | SPI

Discussion Groups

Discussion Groups | Freescale DSPs | Rif: RE: Mathematical function long x long / long

Technical discussions about Freescale (Motorola) DSPs (including the DSP56000, DSP56300, DSP56600, 56800 DSPs).

  

Post a new Thread

Rif: RE: Mathematical function long x long / long - Author Unknown - Nov 11 10:54:00 2002




It's simple to show that

A * (B % C) can overflow!

For example if :
A = 214751
B = 10000
C = 30000

214751 * 30000 = 0x1800134d0

Is it right ?

Regards,
Giuliano
"Harrold Spier"

<harrold.spier@al Per: <>,

tium.nl> <>

Cc:

07/11/02 16.39 Oggetto: RE: [motoroladsp]
Mathematical function long x
long / long

Try:

D = A * (B / C) + /* Main part */
(A * (B % C)) / C; /* Correction with remainder */

Harrold -----Original Message-----
From: [mailto:]
Sent: Thursday, November 07, 2002 15:41
To:
Subject: [motoroladsp] Mathematical function long x long / long Does anyone have implemented a mathematical function to perform D = A *
B / C where A,B,C,D are "signed long" ? Obviusly A * B resualt can
exceed long size value. Thanks, Giuliano _____________________________________
/groups.php3






(You need to be a member of motoroladsp -- send a blank email to motoroladsp-subscribe@yahoogroups.com )

Re: Rif: RE: Mathematical function long x long / long - Jacob Christ - Nov 11 18:32:00 2002

It's simple to show that

D = A * B / C

can overflow no matter how you calculate it if the conditions are
right.
---
A = 0x7FFF FFFF
B = 0x7FFF FFFF
C = 0x1

will never fit in a signed long D, does D have to be a signed long?

Jacob

--- In motoroladsp@y..., giuliano.to@q... wrote:
>
> It's simple to show that
>
> A * (B % C) can overflow!
>
> For example if :
> A = 214751
> B = 10000
> C = 30000
>
> 214751 * 30000 = 0x1800134d0
>
> Is it right ?
>
> Regards,
> Giuliano
> "Harrold
Spier"

> <harrold.spier@al Per:
<giuliano.to@q...>,
> tium.nl>
<motoroladsp@y...>
>
Cc:
> 07/11/02 16.39 Oggetto: RE:
[motoroladsp] Mathematical function long x
> long /
long >
> Try:
>
> D = A * (B / C) + /* Main part */
> (A * (B % C)) / C; /* Correction with
remainder */
>
> Harrold > -----Original Message-----
> From: giuliano.to@q... [mailto:giuliano.to@q...]
> Sent: Thursday, November 07, 2002 15:41
> To: motoroladsp@y...
> Subject: [motoroladsp] Mathematical function long x long / long > Does anyone have implemented a mathematical function to perform D =
A *
> B / C where A,B,C,D are "signed long" ? Obviusly A * B resualt can
> exceed long size value. Thanks, Giuliano > _____________________________________
> /groups.php3




(You need to be a member of motoroladsp -- send a blank email to motoroladsp-subscribe@yahoogroups.com )