Floating point numbers

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

Moderator: Benj

Post Reply
Lagoda
Posts: 170
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 69 times
Been thanked: 61 times
Contact:

Floating point numbers

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

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

Re: Floating point numbers

Post 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 334 times
Let me know how you get on.

Lagoda
Posts: 170
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 69 times
Been thanked: 61 times
Contact:

Re: Floating point numbers

Post 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

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

Re: Floating point numbers

Post 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.

Lagoda
Posts: 170
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 69 times
Been thanked: 61 times
Contact:

Re: Floating point numbers

Post 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
Attachments
float_to_string_test2.fcfx
(9.31 KiB) Downloaded 318 times
Compiler_messages.jpg
(223.62 KiB) Downloaded 87 times
Test_result_on_the_display.jpg
(207.65 KiB) Downloaded 87 times

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

Re: Floating point numbers

Post 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

Post Reply