This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Double precision maths library

Has anyone any idea where I can get a double precision maths library which will work with the Keil C51 compiler.

Parents
  • Hello Hans

    .. yes - it would be me who gets fired!

    I assumed that since the Keil tools claim ANSI C compliance they would include double support, but I was sadly wrong.

    I am just checking my first attempt at a function to 'cast' floats to IEEE754 format doubles (seems okay). I hope it won't take more than a couple of days to get functions to support the four basic maths functions (I also need to do something about printf() of course since I need to display the results of my labours). I had better be right or I might have to find the $5,000 out of my own pocket!

    best regards - Paul

Reply
  • Hello Hans

    .. yes - it would be me who gets fired!

    I assumed that since the Keil tools claim ANSI C compliance they would include double support, but I was sadly wrong.

    I am just checking my first attempt at a function to 'cast' floats to IEEE754 format doubles (seems okay). I hope it won't take more than a couple of days to get functions to support the four basic maths functions (I also need to do something about printf() of course since I need to display the results of my labours). I had better be right or I might have to find the $5,000 out of my own pocket!

    best regards - Paul

Children
  • "I assumed that since the Keil tools claim ANSI C compliance they would include double support"

    This still begs the question as to why you would choose an 8-bit microcontroller to do 64-bit floating point maths?!

    Here is the C51 product description page:

    http://www.keil.com/c51/c51.asp

    Note the 1st bullet point:

    "Nine basic data types, including 32-bit IEEE floating-point"

    The fact that they make specific mention of 32-bit floats should alert you that this is something exceptional for an 8-bit processor!

  • Get a math text book. Four function float will not be that hard add the mantisas adjust the exponents. A better Idea is to take the final formula and hard code it multiplications first then divides.

    Then again it would be easiyer to code 64 bit (or longer) ints than floats

  • Hello Andy

    The processor (Cypress CY7C68013) was chosen becaus it has a built in USB2.0 engine. The Keil tools because a demo came with the Cypress development kit & looked good (still think it is).

    Anyway, I am not disappointed with the choice - unless the processor has a floating-point maths processor someone (compiler supplier or me) has to write some maths software. Going to double precision adds little to the software and probably only costs a factor of little more than 2 on time (4 for multiply). I only need to crunch some precise numbers once every 100ms so this shouldn't be too much of a loading... I will find out when I start coding this tomorrow!

    Thanks & best regards - Paul

  • Thanks for your thoughts Neil

    I have written 32-bit maths routines in assembler (on 6809 processors admittedly & integer only), so this looks less daunting the more I think about it. As you say it is just integer maths on the mantissas but with a watchful eye on the exponent. I plan to write it in C since I am not familiar with 8051 assembler.

    best regards - Paul

  • "The processor (Cypress CY7C68013) was chosen becaus it has a built in USB2.0 engine."

    Presumably, that means that it'll be connected to a PC?

    Could you no send the "raw" data to the PC, have the PC do the number crunching, and perhaps send the results back?

    Or is it not always connected to a PC?