Page 1 of 1

Floating point numbers

Posted: Sun Mar 05, 2017 10:17 pm
by Lagoda
Dear Support,

Maybe I'm doing something wrong but this program works in the simulator, but the compiler is unable to translate this. I use 24FJ256GA110 chip.
Could you help me?

Best Regards:

Lagoda

Re: Floating point numbers

Posted: Mon Mar 06, 2017 11:11 am
by Benj
Hello Lagoda,

Thanks for letting us know of the problem. I have found the cause and hopefully fixed it.

Simply copy the file below into your "Flowcode 7/CAL/PIC16BIT" folder and then compilation should work correctly.
PIC16BIT_CAL_Float.c
(2.84 KiB) Downloaded 340 times
Let me know how you get on.

Re: Floating point numbers

Posted: Mon Mar 06, 2017 4:41 pm
by Lagoda
Hi Ben,
Thanks for the quick help.
Now, the compiler is able to translate but in the simulator only works correctly if I set y=1 in the "fround (x, y)" function.
In the target circuits after the decimal point on the display appears only "0", independently value of "y".

Best Regards,

Lagoda

Re: Floating point numbers

Posted: Mon Mar 06, 2017 4:50 pm
by Benj
Hi Lagoda,

Make sure your not entering any floating point numbers as decimal.

e.g. 1 should be entered as 1.0

Otherwise the compiler will think it's a whole number and use the integer routines to do the maths rather than the floating point routines.

Re: Floating point numbers

Posted: Mon Mar 06, 2017 9:33 pm
by Lagoda
Hi Ben,
Thanks, I'll check again, but if the floating point variable is converted to a string then I see on the display what the value should be rounded.
When I use the "fround" function before converted to string, that happens what I wrote.
I made an example that maybe help.
The function in my project has been solved differently, but I would like to know what is causing the trouble.
I've run out of ideas. :|

Lagoda

Re: Floating point numbers

Posted: Sat Jun 24, 2017 11:38 am
by jadiflow
Benj wrote:Hello Lagoda,

Thanks for letting us know of the problem. I have found the cause and hopefully fixed it.

Simply copy the file below into your "Flowcode 7/CAL/PIC16BIT" folder and then compilation should work correctly.
PIC16BIT_CAL_Float.c
Let me know how you get on.
Good day Ben,

Having had the same problem as Lagoda, I downloaded this same file. I am using an 8-bitter, but from the header of this c-file it appears to be the same for 8- as 16-bit processors. So I replaced the distribution PIC_CAL_Float.c with the renamed PIC16BIT_CAL_Float.c and it worked in the sense that the compiler errors are now gone.

However, I have not been able yet to test if it really works on the hardware. So my question is, will it, or is there another floating point c-file I need to replace the 8-bit library file with.

Jan