Shop OBEX P1 Docs P2 Docs Learn Events
help me — Parallax Forums

help me

ArchiverArchiver Posts: 46,084
edited 2001-05-23 02:30 in General Discussion
Can someone please help me do simple math problem on a bs2?

7501876 / X = Y

" X " is a word size from 0 to 65535

I do not need a decimal point

I don't want to get a math coprocessor from AWC since I will only be using one other problem.

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-05-22 04:27
    Anthony Conti wrote:

    > Can someone please help me do simple math problem on a bs2?
    >
    > 7501876 / X = Y
    >
    > " X " is a word size from 0 to 65535
    >
    Let's see:
    - anything < 115 will give you a value > 65535
    - anything between 115 and about 3000, you could use 60015/X*125
    - anything above 3000, you could use 60015/(X/125)

    Not perfect but it'll get you close to the actual value.

    SD

    --
    /===================================================================\
    | Steve DeGroof (http://degroof.home.mindspring.com/) |
    \===================================================================/
  • ArchiverArchiver Posts: 46,084
    edited 2001-05-22 06:02
    That Idea works great, but I need the stamp to do the math on the fly, so I can't use more then one problem (unless there is a way to do it). I found out the min value for X is 750. for Y I will be dumping the last digit ( 3131 = 3130 ). I was thinking of doing some thing like this

    Y = Y - dig 0

    I think it will work

    TC
  • ArchiverArchiver Posts: 46,084
    edited 2001-05-22 08:20
    Hi anthony,

    7501876 equals 4*31*60499

    Try 60499 / X * 31 * 4 = Y

    Greetings peter
  • ArchiverArchiver Posts: 46,084
    edited 2001-05-22 10:27
    Anthony Conti wrote:
    >Can someone please help me do simple math problem on a bs2?
    >
    >7501876 / X = Y
    >
    >" X " is a word size from 0 to 65535
    >
    >I do not need a decimal point
    >
    >I don't want to get a math coprocessor from AWC since I will only be
    >using one other problem.
    >..
    >I found out the min value for X is 750.


    Hi again TC,

    ' Y=7501876/X approx for 65536>X>256:
    J=ncd X - 8
    Y=65535/X*256+(65535//X<<(8-J)/(X>>J))*/114


    -- Tracy
  • ArchiverArchiver Posts: 46,084
    edited 2001-05-23 02:30
    aconti@n... wrote (personal communication):
    >Tracy that dose not work. If you put in 1000 for X into the stamp you
    >get 7450 for Y, I should get 7501.
    >
    >>Anthony Conti wrote (Stamps):
    >> >Can someone please help me do simple math problem on a bs2?
    >> >
    >> >7501876 / X = Y
    >> >
    >> >" X " is a word size from 0 to 65535
    >> >
    >> >I do not need a decimal point
    >> >
    >> >I don't want to get a math coprocessor from AWC since I will only be
    >> >using one other problem.
    >> >..
    >> >I found out the min value for X is 750.
    >>
    >>Tracy Allen wrote:
    >> Hi again TC,
    >>
    >> ' Y=7501876/X approx for 65536>X>256:
    >> J=ncd X - 8
    >> Y=65535/X*256+(65535//X<<(8-J)/(X>>J))*/114

    TC,

    Actually, if you put in 1000 for X into the stamp you get 7470 (not
    7450) for Y. That is less than 0,5% error.

    Moreover, we can do better, using ** instead of */ for the normalization:

    ' Y=7501876/X approx for 65536>X>256:
    X var word
    Y var word
    J var nib
    for X=500 to 65500 step 500
    J=ncd X - 8
    Y=65535/X*256+(65535//X<<(8-J)/(X>>J))**29304
    debug cr,dec X,tab,dec Y
    next


    Representative values:
    X BS2 Y true Y=7501876/X
    500 15003 15003.75
    1000 7501 7501.86
    1500 5001 5001.25
    5000 1500 1500.38
    8000 937 937.73
    12000 625 625.16
    40000 187 187.55
    65000 115 115.41

    -- regards
    Tracy Allen
    electronically monitored ecosystems
    http://www.emesystems.com/BS2math2.htm <--- explanation of how it works
    mailto:tracy@e...
Sign In or Register to comment.