Shop OBEX P1 Docs P2 Docs Learn Events
Where can I find the class and package downloads. — Parallax Forums

Where can I find the class and package downloads.

javelin nubyjavelin nuby Posts: 27
edited 2009-09-20 17:04 in General Discussion
I lost the link for the Javalin classes and packages.
Specifically I need to do some "floating point" math for scaling my inputs and unit conversion.
Does anyone know where I can download such?

Comments

  • javelin nubyjavelin nuby Posts: 27
    edited 2009-09-20 06:07
    My input values are in the range of 0 to 1023 (tem bit). I need to mulitiply it by 1.48
    I tried to multiply by 148 and divide by 100 but that does'nt work because of divide is only working on 1 word.
    Is there a way to create two words with the Mult. then divide these two words by 100(so that I'm back to one word?
    Maybe somthing like a Double Multiply and Double Divide in PLC programming?
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-09-20 08:06
    The easiest way is to use the UnsignedIntMath class:
    http://tech.groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/math/

    int result = value + UnsignedIntMath.umulf(value,31457); //31457 = 0.48*65536

    But in this case you could do without the class

    1.48 * value = value + ((12*value)/25);

    For a rounded result you can use

    int result·= value + ((24*value + 25)/50);

    regards peter

    Post Edited (Peter Verkaik) : 9/20/2009 11:10:19 AM GMT
  • javelin nubyjavelin nuby Posts: 27
    edited 2009-09-20 17:04
    Thanks again Peter.
Sign In or Register to comment.