Shop OBEX P1 Docs P2 Docs Learn Events
Dynamic math tutorial? — Parallax Forums

Dynamic math tutorial?

JaakkoJaakko Posts: 6
edited 2008-01-03 17:54 in Propeller 1
Hi!
Does anyone know about some newbie tutorial to DML and FloatMath etc. Things like "Can I feed them with signed integers?" or "Do I have to declare that a variable is a signed integer" or "What are the max input values for this op?". You know, a kind of simple rule book for those without degrees in mathematics.

best regards
Jaakko

Comments

  • AleAle Posts: 2,363
    edited 2008-01-03 13:27
    I think that the IEEE 754 takes care of that. OTOH most floating point implementations... have some sort of documentation that tells you all that. If not, well read the source to find out wink.gif
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-03 16:13
    As floating point - wrt constant expressions - is an integrated part of the IDE, there are also hints in the Manual.

    PS.: What do you refer to by "DML"?

    Post Edited (deSilva) : 1/3/2008 5:42:39 PM GMT
  • JaakkoJaakko Posts: 6
    edited 2008-01-03 16:54
    Thank you for your replies,guys!

    I´m a complete newbie but I figured it out; floating point operations need floating point input values and when you want to display the results in the LCD you have to truncate or round them back to integers.Cheers!

    DML is DynamicMathLib, I still haven´t found "idiot proof" data about input value limits.

    best regards

    Jaakko
  • RaymanRayman Posts: 14,162
    edited 2008-01-03 16:55
    I have some info and links on IEEE-754 here:


    http://www.rayslogic.com/TimexUSB/Float.htm

    (Also is some info on the lesser known S16E7 format...)
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-03 17:54
    I knew it had to be deSilva again to read and preach the Manual - reminds me of the time in a Benectine monastery AD 1200 where I also was the only one who could read the only book we had....
    Manual p. 217 said...
    The Propeller compiler handles floating-point constants as a single-precision real number as
    described by the IEEE-754 standard. Single-precision real numbers are stored in 32 bits, with
    a 1-bit sign, an 8-bit exponent, and a 23-bit mantissa (the fractional part). This provides
    approximately 7.2 significant decimal digits.
    This is one of Rayman's links that gives you ALL precise date in an easy way steve.hollasch.net/cgindex/coding/ieeefloat.html

    Now: converting an integer needs:
    float := fm.FFloat(integer)

    rounding it back is
    integer := fm.FRound(float)

    Converting it to a readable string is

    OBJ: fs: "FloatString"

    stringaddress := fs.FloatToString(float)
    But there are more options, read through the comments in the code
Sign In or Register to comment.