Shop OBEX P1 Docs P2 Docs Learn Events
Does the bs2 use BEDMAS in its math? — Parallax Forums

Does the bs2 use BEDMAS in its math?

etc.etc. Posts: 3
edited 2009-02-02 19:39 in BASIC Stamp
I am building this robot, sort of like a snake but different.

Anyway, i am using the Bs2 to send serial instructions to an SSC-32 servo controller by Lynxmotion, and i was wondering if BEDMAS applied to the stamp's math operations. I have a line of code like this:

serout 0, 6, [noparse][[/noparse]"#0 p", DEC e0 * 10, #1 p", DEC 300 - e1 * 10, #2 p", DEC e2 * 10, #3 p", DEC 300 - e3 * 10... etc.



the purpose of the code is to send out commands in the following format. # <servo number> p <pulse width of servo> etc. so i am sending out values for 10 different servos. the servos form sort of a chain, and they face opposite directions, so i am inverting the values of every other servo to remedy this. i also need to multiply all the values by 10. it should end up sending a value like this (x represents the value being fed in, y represents the value being sent out to the servo. (300 - x) * 10

so i was pretty much just wondering if BEDMAS applies to the stamp's math operations, and can i use brackets just like in algebra in the stamp?

Thanks

Post Edited (etc.) : 2/1/2009 1:57:12 AM GMT

Comments

  • FranklinFranklin Posts: 4,747
    edited 2009-02-01 01:46
    You should add a subject to your post. Use the pencil icon in the top of your original post to do that.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • etc.etc. Posts: 3
    edited 2009-02-01 01:55
    thanks i just did. BTW, sorry for the poor explanation of my situation, everyone
  • Adrian SchneiderAdrian Schneider Posts: 92
    edited 2009-02-02 10:47
    as far as i knwo, the stamp basic compiler evaluates algbraic expressions strictly from left to right -- thus no BEDMAS.
    Yes, you can use brackets, you even have to sometimes.
    regards
    adrian
  • etc.etc. Posts: 3
    edited 2009-02-02 16:56
    thanks
  • davejamesdavejames Posts: 4,047
    edited 2009-02-02 19:39
    The "PBasic Operators" section in the programming manual describes the flow of math operations.

    DJ
Sign In or Register to comment.