PDA

View Full Version : handling Large Numbers



Peter1960
- 24th April 2007, 04:22
OK, Brain Freeze !! (At the moment I cannot even get a slope formula right !)

This is what I am trying to do

x var word [2]


ADCIN 6,x

x = x*2923-1343923

x1 = div32 1000

assembly says value truncated

it only allows to max ~63000

help !

Pete

skimask
- 24th April 2007, 04:26
OK, Brain Freeze !! (At the moment I cannot even get a slope formula right !)
This is what I am trying to do
x var word [2]
ADCIN 6,x
x = x*2923-1343923
x1 = div32 1000
assembly says value truncated
it only allows to max ~63000
help !
Pete

Page 31 of the manual, 4th line down...

Peter1960
- 24th April 2007, 04:40
Page 31 4th line down in mine says

** Top 16 Bits of Multiplication

I also found the DIV32, however ?

May I inquire what you were saying, please

Pete

skimask
- 24th April 2007, 04:47
Ok, maybe we've got different versions of the manual, different sections on different pages...I was referring to Section 4.17, but I'm pulling ALL of this straight from the manual:

x var word [2] ---- space between 'word' and '[2]' doesn't work.

ADCIN 6,x ---- this might work, if you set the configuration and defines correctly, which I don't see.

x = x*2923-1343923
---this won't work at all. For one thing, 'x' can't be any larger than 22 at the start of the operation because it'll be over the 16 bit limit. 1,343,923 is actually a 21 bit number. PBP only operates on 16 bit numbers. You might be wanting to do a 16x16=32bit number multiply operation, but you aren't going to do it with a '*'. And even if you did use it correctly, you couldn't subtract 1,343,923 from the result because, again, 1,343,923 is a number that can't be held in 16 bits.

x1 = div32 1000 --- inconsistent usage with the correct way of using it

assembly says value truncated
it only allows to max ~63000 ----- because PBP doesn't deal with numbers larger than 16 bits (65535)...

Darrel Taylor
- 24th April 2007, 04:50
Peter,

It looks like the original formula would have been

y = 0.2923x - 134.39

With a few extra decimal places.

But since you will end up with an integer in the end, you can just round off to -134 for the b parameter (y=mX + b).

For the m parameter, 0.2923 is 2923 ten thousanths. Which is an easy way to remember that you need to divide by 10,000 afterwards.

So you multiply the A/D reading times 2923.
Then divide it by 10,000
Like this...
X VAR WORD
Y VAR WORD

ADCIN 6,X

Y = X * 2923
Y = DIV32 10000
Y = Y - 134

I think that's about as close as you can get with 16/31 bit math.

HTH,

Peter1960
- 24th April 2007, 05:26
Hi Daryl,
Must have been your telepathy, as I did precicly that, ie

div32 first THEN subtract

ADCIN 7,y

Pause 100 ' adc settling

x1 = y

y = y*385

y = div32 1000

y = y - 5088

y1=y1+y ' Loop to average results

If x = 9 then goto outtwo

x=x+1

Pause 100

Goto Ambient

Outtwo: Debug "A raw= ",#x1,$0D,$0A

y=y1/1000

Y1= y1//1000

Y1 = Y1/100

Debug "A calc= ",#y,".",#y1,$0D,$0A

x=0
y=0
y1=0

now results are JUST Fine !!!!
thanks Steve and Daryll

kindregards

pete

sorry Steve is meant to say Skimask

mister_e
- 24th April 2007, 21:13
sorry Steve is meant to say Skimask
Ouf! Thank you very much. I have some reputation to preserve :D


thanks Steve and Daryll
Who's Daryll now? i know the OLD movie (http://www.retrojunk.com/details_trailer/12/), a magician and an OLD guy, but the OLD guy name is DarrEl ;)

Just kidding.

Darrel Taylor
- 25th April 2007, 10:14
Who's Daryll now?

That's my brother Daryll.
Then there's my other brother Darryl. :)
<br>

paul borgmeier
- 25th April 2007, 15:12
I think you have some cousins too

http://www.thinkbabynames.com/search.php?g=1&t=1&s=darrel

mister_e
- 25th April 2007, 15:27
mmm, the first chart confirm something ... http://www.mister-e.org/Pics/ROFL
<img SRC="http://www.thinkbabynames.com/graph.php?g=1&c=0&1=Darrel">
Now, let's see ...
<img SRC="http://www.thinkbabynames.com/graph.php?g=1&c=0&1=Darrel&2=Daryl&3=Darryl&4=Darel&5=Dariel&6=Dariell&7=Darral&8=Darrell&9=Darrill&10=Darrol&11=Darroll&12=Darry&13=Darryll&14=Derell&15=Derrall&16=Derrel&17=Derrell&18=Derril&19=Derrill&20=Deryl">

so, it's normal that many people change the spelling with ages... as it's an old old way to spell it... hence an old old name... hence OLD OLD guy to.

LMAO!

Darrel Taylor
- 25th April 2007, 21:38
as it's an old old way to spell it... hence an old old name... hence OLD OLD guy to.

Sometimes there's just too much information on the internet. :)

Excuse me a moment. It's time for my Geritol.
<br>

mister_e
- 25th April 2007, 21:43
well... i hold myself to post what else i found ... anyway, you know it's just for fun don't you?



Excuse me a moment. It's time for my Geritol.
wooohooo another blast from the past ;)

Don't forget to put some 'Brylcreem' in your hair as well :D

Archangel
- 26th April 2007, 02:33
well... i hold myself to post what else i found ... anyway, you know it's just for fun don't you?


wooohooo another blast from the past ;)

Don't forget to put some 'Brylcreem' in your hair as well :D

At our age it's more likely Denturecream ! :)

" You don't get old by being a fool "
" a lotta young wise men, deader than a motherf. ..."
"Richard Pryor"