Author Topic: [Help needed] 3-4 byte numbers  (Read 9508 times)

0 Members and 1 Guest are viewing this topic.

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: [Help needed] 3-4 byte numbers
« Reply #15 on: December 04, 2010, 01:08:55 pm »
now about square roots?
Well, it involves a few different things.  I know of newton's recursive algorithm.  It would require two four byte numbers.  So, essentially, recursively do this formula: (I think. I could be wrong. Just search newton's method for square roots. Note that there are also better methods for a binary system than this.)
((N/X)+X)/2

ASHBAD_ALVIN

  • Guest
Re: [Help needed] 3-4 byte numbers
« Reply #16 on: December 04, 2010, 01:19:54 pm »
what are N and X?

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: [Help needed] 3-4 byte numbers
« Reply #17 on: December 04, 2010, 02:39:48 pm »
Why don't you use a bit of Assembly and just make the proper B_calls? The TI-OS routines already work with 9 byte numbers, so you would just need to throw away the guard digits.

And Graph, Newton's method works, but it can be slow to converge.
« Last Edit: December 04, 2010, 02:40:48 pm by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: [Help needed] 3-4 byte numbers
« Reply #18 on: December 04, 2010, 03:04:29 pm »
because i have -9000 experiance with assembly.
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

Ashbad

  • Guest
Re: [Help needed] 3-4 byte numbers
« Reply #19 on: December 04, 2010, 03:42:17 pm »
at least he doesn't have < -9000 asm experience...

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: [Help needed] 3-4 byte numbers
« Reply #20 on: December 04, 2010, 07:08:11 pm »
I can help you write a routine if you can give me a better description of what exactly you need to do.

Here is a routine to add the first 2 arguments and store the result in the third.  Each argument is a pointer to a little endian 4 byte number.


:Lbl ADD
:{r1}r+{r2}r->r4
:>{r1}r+{r1+2}r+{r2+2}r
:->{r4->{r3}r+1}
:Return

So This:

sub(ADD,oA,oC,oE)

Would do  FE = BA + DC
« Last Edit: December 04, 2010, 07:08:57 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: [Help needed] 3-4 byte numbers
« Reply #21 on: December 04, 2010, 07:34:34 pm »
Please correct me if I'm wrong, but shouldn't that greater than sign be a less than sign? The addition carried if the 16-bit result is less than a 16-bit input.

Also, I think you need an r modifier on the end of the last line.

Also, optimization: (Me optimizing Quigibo's code? It must be backwards day!)
Code: [Select]
:Lbl ADD
:{r₁}ʳ→r₅+{r₂}ʳ→r₄
:<r₅+{r₁+2}ʳ+{r₂+2}ʳ
:→{r₄→{r₃}ʳ+1}ʳ
:Return

You could also optimize it a bit more by restructuring the inputs to be in the order of (result,input1,input2):
Code: [Select]
:Lbl ADD
:{}ʳ→r₅+{r₂}ʳ→r₄
:<r₅+{r₃+2}ʳ+{r₂+2}ʳ
:→{r₄→{r₁}ʳ+1}ʳ
:Return
« Last Edit: December 04, 2010, 07:37:49 pm by Runer112 »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [Help needed] 3-4 byte numbers
« Reply #22 on: December 04, 2010, 09:54:47 pm »
Why don't you use a bit of Assembly and just make the proper B_calls? The TI-OS routines already work with 9 byte numbers, so you would just need to throw away the guard digits.

And Graph, Newton's method works, but it can be slow to converge.
Let's not start with the whole "learn asm" thing. This is very 2004 and is trolling. He asks Axe help so he needs ask help. Telling him to learn ASM is not helping him, unless it was absolutely impossible to do so.

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: [Help needed] 3-4 byte numbers
« Reply #23 on: December 09, 2010, 07:04:09 am »
Yeah, I know Newton's method is slow to converge, but I figured with 3-4 byte numbers that it wouldn't be that bad. I don't know of any algorithms for square roots of BCD numbers, though.