Computing write/read speed
Kye
Posts: 2,200
I'm trying to do some integer only math using spin and I'm encountering some overflow problems.
Basically I have the cnt difference from the start of writing to a file and from the end of writing to a file. However,·the value goes above POSX.
What I want to do (as if I had floating point) is:
timeDelta = ((stopCNT - startCNT) / clkfreq)
and
bytesPerSecond = (131072 / timeDelta)
---
The problem with doing this is that if the value is rather low with integer only math I need to scale it up. Buf if I do that every time then if the value is to high I will have an overflow.
Then I also have the problem of SPIN's signed math, if the value is above POSX then its hard to do math in the first place on the value.
...
So what can I do?
Thanks for your help,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
Basically I have the cnt difference from the start of writing to a file and from the end of writing to a file. However,·the value goes above POSX.
What I want to do (as if I had floating point) is:
timeDelta = ((stopCNT - startCNT) / clkfreq)
and
bytesPerSecond = (131072 / timeDelta)
---
The problem with doing this is that if the value is rather low with integer only math I need to scale it up. Buf if I do that every time then if the value is to high I will have an overflow.
Then I also have the problem of SPIN's signed math, if the value is above POSX then its hard to do math in the first place on the value.
...
So what can I do?
Thanks for your help,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
Comments
-Phil
Post Edited (kuroneko) : 5/24/2010 1:34:24 PM GMT
As Marko indicates, the is good for durations up to CLKFREQ/2.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA