Shop OBEX P1 Docs P2 Docs Learn Events
raise a number to the power of another number — Parallax Forums

raise a number to the power of another number

WhatamINutsWhatamINuts Posts: 6
edited 2009-10-09 21:02 in BASIC Stamp
Greetings
·· Another crazy question
· I need to implement this Formula on the BS2
··· X^y/x· Where ^ is "to the power of"
·X is a constant of my choice·and Y is a Variable between 1000 and 3000
······· Any ideas ?
· Thanks
··· Have Fun
········ Tim

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-10-08 19:40
    The largest native data type in PBASIC is WORD, which is 16 bits long and has a dynamic range of 0 to 65535. It would be completely unrealistic to raise any number greater than 1 to the 1000th power, given this limitation. You could keep your result as a logarithm:

    ····log221000 = 1000

    but the resulting loss of precision may be more than your app could sustain.

    -Phil
  • Redd DawgRedd Dawg Posts: 26
    edited 2009-10-08 19:44
    And here is where you can get some logs and other great math info.

    http://www.emesystems.com/BS2math3.htm

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • WhatamINutsWhatamINuts Posts: 6
    edited 2009-10-08 19:58
    Thanks very much for the info.
    · I will try the log function as the precision isnlt as important as the curve generated by the numbers.
    · I can easily scale the output to what I need.
    ··· Thanks Again
    ···· Have Fun
    ········ Tim
    ·PS
    · The real problem with my approach on the stamp is
    ·X^y/x· Where ^ is "to the power of"
    ·X is a constant of my choice·and Y is a Variable between 1000 and 3000
    ·······
    ·The Y/x becomes· a fraction say 1000/2500 so I end up with
    ·· 2500^(1000/2500)= 22

    Post Edited (WhatamINuts) : 10/8/2009 8:14:02 PM GMT
  • WhatamINutsWhatamINuts Posts: 6
    edited 2009-10-09 21:02
    Just wanted to say thanks for the help
    ·· Problem solvedyeah.gif
Sign In or Register to comment.