Shop OBEX P1 Docs P2 Docs Learn Events
*/ and ** operator — Parallax Forums

*/ and ** operator

TumblerTumbler Posts: 323
edited 2007-06-02 07:18 in BASIC Stamp
Hello,

Can somebody tell me what the */ and the ** operators do?
and are there more of these?

grtz

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-06-01 06:14
    Have a look at the Stamp Basic manual which you can download from the Parallax main webpage ... Downloads menu item ... Documentation submenu.

    Also, Tracy Allen's website discusses these under "math" (see: www.emesystems.com).
  • BeanBean Posts: 8,129
    edited 2007-06-01 11:51
    x */ y = (x * y) / 256
    x ** y = (x * y) / 65536

    Note that the (x * Y) value CAN exceed the 65535 limitation.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    “The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • edited 2007-06-01 18:53
    */ and ** are the PBASIC's alternative to floating point for multiplying by fractional values. */ multiplies a value by a number of 256ths, and ** multiplies by a number of 65536ths.

    Example: Want to multiply a value by pi in PBASIC? Multiply pi by 256 and you get 804.247... So, you can use 804 with */

    result = value */ 804············· '·Multiply by ~ pi

    Example: Want to multiply a value by 1/sqrt(2) ~ 0.707? You can use */, but ** will give you a more accurate result. Multiply 1/sqrt(2) by 65536, and you get 46340.95..., so use 46341 with **:

    result = value ** 46341········· ' Multiply by ~ 1/sqrt(2)

    With */ you can multiply by fractional values that are less than 256. With **, you can multiply by values that are less than 1 (max 65535/65536).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.

    Post Edited (Andy Lindsay (Parallax)) : 6/1/2007 11:58:45 PM GMT
  • TumblerTumbler Posts: 323
    edited 2007-06-02 07:18
    Ok, thx all
Sign In or Register to comment.