Shop OBEX P1 Docs P2 Docs Learn Events
Floating Point BASIC — Parallax Forums

Floating Point BASIC

HumanoidoHumanoido Posts: 5,770
edited 2011-01-13 15:43 in Propeller 1
Why is there no floating point BASIC programming language for the Propeller, that can run from the chip, like a special FP Femtobasic version?

Comments

  • localrogerlocalroger Posts: 3,452
    edited 2011-01-13 07:43
    Floating point eats a helper cog and is far slower and less efficient than integer math. Almost everything you'd ever use floating point for can be done better with integer math if you understand the problem. The exceptions to that are rare enough that you don't need native language support for the math.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-01-13 07:56
    I've thought about doing a floating point version of FemtoBasic. It would not be that much slower than the existing FemtoBasic because most of the time is currently spent in the slow Basic interpreter. The arithmetic is a relatively small part of what gets done. The floating point routines would take up memory that might be used for the program unless a lot of changes were made to try to reuse the memory used to initialize the cogs for the various I/O drivers. Mostly it would be a lot of work to do properly. A "quick and dirty" version could be done quickly though.
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-01-13 08:15
    localroger wrote: »
    Floating point eats a helper cog and is far slower and less efficient than integer math. Almost everything you'd ever use floating point for can be done better with integer math if you understand the problem. The exceptions to that are rare enough that you don't need native language support for the math.
    You make a very good point that almost anything can be created in integer BASIC. For years I used Tiny BASIC creating all these math routines and figuring out decimals. Then the TRS-80 Model I Level II came along with their new version of float BASIC and OMG, it was fantastic! In my mind, let FP eat a helper cog and let it run slower. It would be extremely useful to have it on the Propeller chip, even a quick and dirty version!
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-01-13 08:20
    Mike Green wrote: »
    I've thought about doing a floating point version of FemtoBasic. It would not be that much slower than the existing FemtoBasic because most of the time is currently spent in the slow Basic interpreter. The arithmetic is a relatively small part of what gets done. The floating point routines would take up memory that might be used for the program unless a lot of changes were made to try to reuse the memory used to initialize the cogs for the various I/O drivers. Mostly it would be a lot of work to do properly. A "quick and dirty" version could be done quickly though.
    Mike, your God-like ability to create a "quick and dirty" FP version of FemtoBASIC would be immensely appreciated!
  • SapiehaSapieha Posts: 2,964
    edited 2011-01-13 09:41
    Hi all.

    I think at One COG F32 are good candidate for that
  • localrogerlocalroger Posts: 3,452
    edited 2011-01-13 09:44
    Humanoido, I made the exact opposite transition -- I learned on what was then called Level II Basic with nothing but floating point math, and ended up hacking Tiny Basic to add enough functionality to get an environment that I considered usable. I disagree with Mike that FP Basic wouldn't be much slower. When you use it for everything it's amazing how much bloat FP adds.

    Also, while FP is convenient my experience is that people come to depend on it as a crutch without realizing that it has limitations too, and they get into all sorts of trouble with rounding errors and precision loss which they wouldn't if they were fussing with the decimal points manually and paying attention to where they lie.
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-01-13 15:02
    localroger wrote: »
    Humanoido, I made the exact opposite transition -- I learned on what was then called Level II Basic with nothing but floating point math, and ended up hacking Tiny Basic to add enough functionality to get an environment that I considered usable. I disagree with Mike that FP Basic wouldn't be much slower. When you use it for everything it's amazing how much bloat FP adds.

    Also, while FP is convenient my experience is that people come to depend on it as a crutch without realizing that it has limitations too, and they get into all sorts of trouble with rounding errors and precision loss which they wouldn't if they were fussing with the decimal points manually and paying attention to where they lie.
    Roger, that's a very interesting take on going from a floating point language to an integer language. Well, yes, everything in life has some caveat or another, but there are strong advantages too. I can see how going either way from FP to INT or INT to FP would be instructional, educational and lots of fun. I hope we can have the best of both worlds on the Propeller! BTW, Roger, you must be on cloud 9 with the Propeller and the integer version of FemtoBASIC. Maybe we'll start a thread to share some of those INT routines...

    Sapieha, it's remarkable you are already calculating that a single cog can handle F32. I think you're heading towards something really wonderful. Perhaps you can work with Mike on this..
  • Heater.Heater. Posts: 21,230
    edited 2011-01-13 15:11
    Humanoido,
    Sapieha, it's remarkable you are already calculating that a single cog can handle F32. I think you're heading towards something really wonderful.

    There is already a single COG float 32 object, it has all the functions of the older two COG version but in one COG and a bit faster and better accuracy here and there.

    F32 is by Lonesock and is in OBEX I believe.
  • SapiehaSapieha Posts: 2,964
    edited 2011-01-13 15:18
    Hi Humanoido.

    I only carefully read every thread that people post on FORUM

    Humanoido wrote: »

    Sapieha, it's remarkable you are already calculating that a single cog can handle F32. I think you're heading towards something really wonderful. Perhaps you can work with Mike on this..
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-01-13 15:20
    Heater. wrote: »
    Humanoido, There is already a single COG float 32 object, it has all the functions of the older two COG version but in one COG and a bit faster and better accuracy here and there. F32 is by Lonesock and is in OBEX I believe.
    Heater, excellent, I see it. But can it seamlessly integrate into FemtoBASIC?
  • Heater.Heater. Posts: 21,230
    edited 2011-01-13 15:30
    No idea, but Lonesock has written it in such a way that it can be used without any of the normal Spin access methods.
    It works through a mailbox approach.
    I have used it with C and the Zog interpreter so I guess it can be dropped into any other language system similarly.
  • Gregg HarringtonGregg Harrington Posts: 16
    edited 2011-01-13 15:43
    I have been running into a similar issue. I am trying todo some on board navigation with a prop chip, but would prefer to handle some of the calculations at very high speeds in float math and not in Integer math. One thought I have had is to include a floating math co-processor into my design. However, I haven't used one yet. Has anyone here tried something along those lines.

    I was considering this chip http://www.sparkfun.com/products/8129

    Parallax has a discontinued version of this chip, but is out of stock.
Sign In or Register to comment.