Floating point numbers

A forums to allow bugs and problems with Flowcode v7 to be reported and resolved.

Moderator: Benj

Lagoda
Posts: 152
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Floating point numbers

Postby Lagoda » Sun Mar 05, 2017 10:17 pm

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
Attachments
float_to_string_test.fcfx
(5.32 KiB) Downloaded 136 times

User avatar
Benj
Matrix Staff
Posts: 14676
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4660 times
Been thanked: 4284 times
Contact:

Re: Floating point numbers

Postby Benj » Mon Mar 06, 2017 11:11 am

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.94 KiB) Downloaded 144 times


Let me know how you get on.
These users thanked the author Benj for the post:
Lagoda (Mon Mar 06, 2017 4:41 pm)
Rating: 5%
 

Lagoda
Posts: 152
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Re: Floating point numbers

Postby Lagoda » Mon Mar 06, 2017 4:41 pm

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

User avatar
Benj
Matrix Staff
Posts: 14676
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4660 times
Been thanked: 4284 times
Contact:

Re: Floating point numbers

Postby Benj » Mon Mar 06, 2017 4:50 pm

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.

Lagoda
Posts: 152
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Re: Floating point numbers

Postby Lagoda » Mon Mar 06, 2017 9:33 pm

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
Attachments
float_to_string_test2.fcfx
(9.31 KiB) Downloaded 128 times
Compiler_messages.jpg
(223.62 KiB) Downloaded 87 times
Test_result_on_the_display.jpg
(207.65 KiB) Downloaded 87 times
These users thanked the author Lagoda for the post:
Benj (Tue Mar 07, 2017 11:01 am)
Rating: 5%
 

jadiflow
Flowcode v5 User
Posts: 249
Joined: Thu Apr 17, 2008 9:59 am
Has thanked: 16 times
Been thanked: 16 times
Contact:

Re: Floating point numbers

Postby jadiflow » Sat Jun 24, 2017 11:38 am

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