## DSP arithmatic. Divisio?

Scope and XITE Development

Original topic on PlanetZ: https://forums.scopeusers.com/viewtopic.php?t=25765

#### DSP arithmatic. Divisio?

Posted: Mon Aug 04, 2008 3:49 am
by irrelevance
Ok so I know that 2* 32 gives us 4294967296 and a bipolar value can swing anywhere between this value. The reason I use the term swing is because I find it easier to think of the value as a positive/negative voltage variation. I have had problems with some simple division though.
There doesn't seem to be a way of applying logic to bipolar values so I figure if I can turn these values into logic sensible 1 and 0's then I can perform simple or complex logic functions this way.
Are you still with me?
Two identical values fed into a division module should to my mind output a value equal to 1 and it does. Strangely enough some values (not all) greater than the other still equal 1? I haven't checked if the values that do provide this outcome vary between projects, although that would certainly be interesting
Is there another way to perform simple division?

#### Re: DSP arithmatic. Divisio?

Posted: Mon Aug 04, 2008 6:45 am
by astroman
there is no such thing as a simple division on computers...
if I remember correctly Wolf(?) once posted an example in this context
imagine the numbers between -max and +max with the zero marking the 'center'
in number theory that point is infinitesimal small, but that doesn't really work in computer math
so there's an 'overhang' of the zero (representation), dunno if it's into the positive or negative direction, but it is there and it's the reason for some funny math results.
cheers, Tom

#### Re: DSP arithmatic. Divisio?

Posted: Mon Aug 04, 2008 8:32 am
by irrelevance
Hey Astro thanks for the reply. May have sounded like a bit of a dumb question but it was meant in context to the SDK functions. DSP arithmetic is an interesting subject as you hinted at and I have been prowling the internet for examples and such:
http://www.dspdesignline.com/showArticl ... =196603215
and this
http://www.ecs.umass.edu/ece/koren/arith/simulator/
Not sure what these algos are at the moment

#### Re: DSP arithmatic. Divisio?

Posted: Mon Aug 04, 2008 9:32 am
by Shroomz~>
Some worthwhile quotes from another thread that I found helpful:-

> j9k wrote:one of the things that will kill you right off the bat is x+y=(x+y)-1 above zero in the mix2 mdl. you have to correct for it if you want to do any sort of integration(like the trapezoid mdl). but this only comes into play in a few circumstances.
> j9k

> at0m wrote:Shroomz,
> I think j9k means that in the total 2^32 numbers, there's 2^31 negative numbers, 0, and then "2^31 - 1" positive numbers.
> There's no center position here in 2^32 or 32bit land, but the 0 is the first positive number. Try doing some proper maths with that

> j9k wrote:1+1=1
> 2+2=3
> 10+10=19
> 2147483647*1024=1023

#### Re: DSP arithmatic. Divisio?

Posted: Mon Aug 04, 2008 11:20 am
by irrelevance
Yep very helpful thanks shroomz

#### Re: DSP arithmatic. Divisio?

Posted: Mon Aug 04, 2008 4:46 pm
by hifiboom
0 is indirectly the center.
respresentation for the whole audio amplitude is 32bit.
That means:
so you got 31bits for positive values and the same 31 bits represent the negative values ( both 1-2147483648)
the first bit (32) holds the flag for the sign, (f.e "1" for "+" and "0" for "-" or the other way round, not important)
in coding world you can specify a variable to be signed or unsigned....
In Scope we have 32 bit audio signed.... so 31bit with a last bit for sign.
so all in all you have 4294967296 values.... or 2147483648 "+" values and 2147483648 "-" values.
The max value "+2147483648" is representing the maximum amplitude "+1"
The min value "-2147483648" is representing the minimum or maximum negative amplitude "-1"
"0" is the the center or DC line.....
now if you multiply "+2147483648" with 1024, its similar to "+1" * 1024, you get 1024.
the error 1+1=1 nad 2+2=3 and so on is due to the zero being part of the positive values from what i know, but this error is neglible......

#### Re: DSP arithmatic. Divisio?

Posted: Mon Aug 04, 2008 4:53 pm
by hifiboom
a little illustration picture for basic understanding....
hope that helps.

Attachments
    signed unsigned_explain.JPG (11.6 KiB) Viewed 2934 times

#### Re: DSP arithmatic. Divisio?

Posted: Mon Aug 04, 2008 4:55 pm
by hifiboom
so if you multiply a wavefrom with ~1073741824 it is the same like multiplying with 0,5 or halfing the amplitude.
So a multiplyer is nothing else like a gain leveler if you input a fixed number at one input....
if you add too audio streams the multiplier is a ringmodulator.... sadly not aliasing free.
a multiply of a waveform with a fixed negative value flips the original wave source. (like the modular diode) positive values get negative and negative get positive.

#### Re: DSP arithmatic. Divisio?

Posted: Tue Aug 05, 2008 12:33 am
by astroman

> irrelevance wrote:... but it was meant in context to the SDK functions. DSP arithmetic is an interesting subject as you hinted at ...

actually I had exactly that thread in mind which Shroomz brought to attention, thanks for the proper quote.
I perfectly fit this thread as I'm a total zero if it comes to that kind of math
cheers, Tom

#### Re: DSP arithmatic. Divisio?

Posted: Tue Aug 05, 2008 5:09 am
by tgstgs
well to be more precise;
2^32 = 256*256*256*256 each represented as a hexvalue FF FF FF FF makes 4294967296 possible values;
being:
–2147483648 to 2147483647 which is __int32 or long signed;
and
0 to 4294967295 is unsigned long;
-----
this is the same in all languages even with your pocket calculater FF FF FF FF HEX is 4294967295 DEZ!!
-----------
but i think the probl. you got with division is course of integer -> simply use float or double!
good vibes from vienna