Shop OBEX P1 Docs P2 Docs Learn Events
How to divide by 3.6 in basic stamp? — Parallax Forums

How to divide by 3.6 in basic stamp?

CuriousOneCuriousOne Posts: 931
edited 2013-07-16 05:01 in BASIC Stamp
Hello.

I'm doing some experiments with lithium battery capacity measuring device using basic stamp. It is very simple, uses MAX7219 as display decoder and 4 segment 7 char LED. However, for accurate capacity display in mAh I need to divide variable by 3.6, which is not supported by stamps. The workaround is to X*10/36, but the problem is, the situation where X*10>65536 will be often, so it does not works. even X*5/18 does not works. X*3/11 may work, but will give bad precision.

Any ideas?

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2013-07-16 04:51
    So, if X is going to be more than 6553, just do a test for how big X is. If less than 6553, do 10/36. If larger, divide by 36 first.

    Cheers,
  • BeanBean Posts: 8,129
    edited 2013-07-16 05:01
    It's been awhile since I used the basic stamps, but I think you can use the ** operator.
    I'm gussing it would be ** 18205 to divide by 3.6

    x = x ** 18205

    Bean
Sign In or Register to comment.