Shop OBEX P1 Docs P2 Docs Learn Events
bs2 cant do it...Can the Propeller? — Parallax Forums

bs2 cant do it...Can the Propeller?

gennarobasso81gennarobasso81 Posts: 84
edited 2012-07-02 13:50 in General Discussion
Hello again everyone,

Quick yes or no question.

The BS2 cannot do integer math. It will round down to the nearest whole number to keep it with in a given range for an assigned value making it difficult to get more exact and precise messurements.

Can a propeller chip handle interger math (or any other chip parallax sells)?

Comments

  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-06-29 09:35
    Not sure you understand what integer math is. It doesn't require rounding.

    The Propeller can do integer and floating point and logs and sines. It is all there.
  • tobdectobdec Posts: 267
    edited 2012-06-29 09:37
    And its allot easier now if you know C since we have GCC for Propeller now...ahh float operands in ANSI-C!
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2012-06-29 09:51
    Integer math is what the BS2 does do. Don't give up! There are tricks and techniques. See http://www.emesystems.com/BS2index.htm#math for ideas.

    The propeller natively does integer math, but it has better handling of negative numbers, and its long variables offer hugely more range to play with if you want to stick to lean and mean integer and fixed point math. The prop also has the rudiments of floating point variable types, and it takes a separate object like F32 with methods to take full advantage of that.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-06-29 09:53
    EVERY microcontroller does INTEGER math. So how can we deny it?
  • kwinnkwinn Posts: 8,697
    edited 2012-06-29 20:33
    EVERY microcontroller does INTEGER math. So how can we deny it?

    Very true but not every micro does 32 bit integer add/subtract with a single instruction.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-06-30 07:13
    The truth is that for real 'micro-controlling', integer math is all you really need. Floating Point, Logs, and Trig functions are mostly for those that use a spreadsheet on a desktop.

    Nobody does a loop 6.69 times or jumps to address 9534.55639. For the occasional need to convert output to some calibrated percentage, there are ways to get around the problem.

    We are not doing finance applications; nor are we calculating the half life of plutonium. It is about controlling devices, sensing, and buffering data. Even decimal is rather an annoyance, might as well count in 16s - called hexadecimal.
  • kwinnkwinn Posts: 8,697
    edited 2012-06-30 08:52
    ............. nor are we calculating the half life of plutonium. It is about controlling devices, sensing, and buffering data. Even decimal is rather an annoyance, might as well count in 16s - called hexadecimal.

    Not always true. For assays and calibrations using some short half life isotopes you need to calculate the corrected DPM for the standards when each standard and sample is counted. If you don't do that the errors get larger as you proceed through the samples. This is typically done on a PC after the sample counts and time have been recorded but for a standalone instrument in the field this can also be done by the microcontroller.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-06-30 09:27
    Yeah, sometimes for an application you may need to use multiple precision calculations, possibly with fixed point scaling, but it's even rarer that you would need floating point with its limited precision (you need to sacrifice bits for the exponent). It's nice that we have 32-bit integer microcontrollers now with provisions for multiple precision arithmetic (like the Prop). We have a really well done floating point library for that and it's reasonably fast as well. The Stamps can do limited multiple precision arithmetic in software. If you need better than that, use a Propeller.
  • frank freedmanfrank freedman Posts: 1,983
    edited 2012-07-01 22:05
    The truth is that for real 'micro-controlling', integer math is all you really need. Floating Point, Logs, and Trig functions are mostly for those that use a spreadsheet on a desktop.

    Nobody does a loop 6.69 times or jumps to address 9534.55639. For the occasional need to convert output to some calibrated percentage, there are ways to get around the problem.

    We are not doing finance applications; nor are we calculating the half life of plutonium. It is about controlling devices, sensing, and buffering data. Even decimal is rather an annoyance, might as well count in 16s - called hexadecimal.

    Actually there are many scientific and control applications which performed all of the various functions mentioned long before math co-processors were in existence. An interesting feature of the Prop is the choice of look-up tables.

    Some links to follow:

    http://www.afcea.org/signal/articles/templates/SIGNAL_Article_Template.asp?articleid=843&zoneid=142

    o
    r

    http://degiorgi.math.hr/~singer/aaa_sem/Div/97-105.pdf



  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-07-02 00:58
    What I love about Parallax's approach is that less hardware combined with more intelligent use of software tends to be their first choice. Why just buy and hope something works for you, when you can be assured that the code you created is right or repairable?
  • gennarobasso81gennarobasso81 Posts: 84
    edited 2012-07-02 12:58
    Im sorry if i misspoke when i first posted this tread. I think mostly everyone got the point though...Yes?

    Thank you to everyone for replying and again... love this community forum

    Parallax really is a good company. Think I'll have to look up if you're traded publicly...lol
  • tonyp12tonyp12 Posts: 1,951
    edited 2012-07-02 13:50
    If you don't just want whole numbers, there is fixed point.
    make everything 8 or 16 times bigger etc

    Say you have 10 and want to add 0.5, shift everything left 4 steps for x8
    80+4= 84
    Spin uses 16bit fixed point, so the smalllest number in decimal you can add or sub is 1 / 65535th of a point.
Sign In or Register to comment.