Has anyone any idea where I can get a double precision maths library which will work with the Keil C51 compiler.
Hello Dave Have never used the forum before, but I have been driven here by the same need... my project required greater precision than 'float' & I have discovered the hard way that the Keil tools (otherwise very good) ignore the 'double' declaration. You can get a double precision maths library that Keil claim will do the job... it's called GoFast from microdigital (see http://www.smxinfo.com) but it costs around $5,000. I cannot justify the cost as all I need is the four basic functions (+ - / and *). I have had a quick look at the problem & it seems this could be done as C functions (using a union to create the data type & writing functions to do the maths) - if this is all you need, do you want to collaborate on writing & testing these? BR Paul
Can you still buy those 8087 maths co-processors...?
Hello Andy I am new to using forums, so not sure if I am supposed to answer this or was it for the originator - anyway... not sure about availability of 8087s, but in my case the hardware is fixed so I will work towards a firmware solution. thanks - Paul
it was just a nutty idea!
my project required greater precision than 'float' I'm afraid I'll have to suggest you consider firing whoever decided to use an 8051 as the CPU for that project, then. If that means you'll have to fire yourself --- well, too bad. but it costs around $5,000 So what? How long can you afford working on such a library yourself, for that amount of money? Do you expect you can finish a robust product in that time, starting from zero?
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
"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
Hi Paul I see what you mean about the price - how on earth do they justify that! We have decided that we can just about do the job by using 64 bit integers providing we put some code in place to stop the the numbers overflowing so we will not need to do anything more, but thanks for the offer! I wish you well with your task and if I can help in any way don't hesitate to contact me. Dave
"I see what you mean about the price - how on earth do they justify that!" Have you tried adding-up how long you've spent on this so far? Give this to your accounts department, and ask what cost it represents - be sure to get the full cost, with full overhead weighting, etc. And don't forget the costs of testing, maintenance, documentation, etc, etc,... They may even want to factor-in the time that you haven't been spending on other work...
It's interesting to note that ANSI requires only a minimum 10 digits of precision for a double and 6 for a float. In fact, that is the only difference in requirements between the two. Long double has the same minimum requirements as double. I don't know whether there is an exemption for freestanding implementations from supporting 10 digit doubles or if this is an example of 'ANSI compliance' being slightly redefined. Either way, I don't think the ANSI minimum requirements for double are in line with most people's expectations.
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
Good lukc Dave I am going to write some functions to extend the maths to do double precision floating-point maths (+ - / * only) - it doesn't look too hard. Just let me know if you would like to receive a copy. best regards - Paul
Hello Ian Yes - this one had me perplexed. 10 decades would be enough for me, but since the IEEE format calls for 8 bytes with a 53-bit mantissa (including the assumed leading 1) I don't know why ANSI C only calls for 10 decades. Since the maths will be coded in binary, I will used all the mantissa bits, which will give me over 15 decades of respolution. best regards - Paul
It was mentioned before, let me repeat (with a suggestion). Why did you choose an 8 bit processor to do 64 bit processing? 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). There are several ARM derivatives with USB 2.0 built in e.g Philips. They will cost about the same as the '51 derivative. Erik