Int to Float

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
Eric
Posts: 99
Joined: Tue Nov 06, 2007 11:04 pm
Been thanked: 1 time

Int to Float

Post by Eric »

Hello,

What is the correct way to convert an Int to Float in V4?
I tried a test with this program:
snap0132.jpg
snap0132.jpg (21.61 KiB) Viewed 6096 times
snap0134.jpg
snap0134.jpg (10.42 KiB) Viewed 6096 times
It simulates but it won't compile, giving this error:
snap0131.jpg
snap0131.jpg (11.62 KiB) Viewed 6096 times
Searching the forum didn't clarified this. What went wrong?

Regards,

Eric

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: Int to Float

Post by Benj »

Hello Eric

Using BoostC this is a little awkward.

You can do the following.

Using a C code icon and the flowcode variables fl_var and int_var.

FCV_FL_VAR = float32_to_int32(FCV_INT_VAR);

There are further functions available inside the calculation icon which can be used to do floating point calculations in BoostC. These functions will work inside the calculation icon.

Hope this helps.

Eric
Posts: 99
Joined: Tue Nov 06, 2007 11:04 pm
Been thanked: 1 time

Re: Int to Float

Post by Eric »

Not really, I still have errors.
snap0135.jpg
snap0135.jpg (23.39 KiB) Viewed 6059 times
Can you please verify or complete this test program so that this program works?
Test1.fcf
(5 KiB) Downloaded 371 times
Thx,

Eric

User avatar
Steve
Matrix Staff
Posts: 3434
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Re: Int to Float

Post by Steve »

Please try float32_from_int32 instead.

We will add these conversion routines into Flowcode itself so you do not need to resort to C code.

Eric
Posts: 99
Joined: Tue Nov 06, 2007 11:04 pm
Been thanked: 1 time

Re: Int to Float

Post by Eric »

Good idea, because float32_from_int32 also gives similar errors.

Regards,

Eric

Eric
Posts: 99
Joined: Tue Nov 06, 2007 11:04 pm
Been thanked: 1 time

Re: Int to Float

Post by Eric »

And please don't wait until V5.
Send us an Flowcode 4.1 update :-)

Rgds,

Eric

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: Int to Float

Post by Benj »

Hello Eric

Here is a working version of your program.
Attachments
Test1.fcf
(5 KiB) Downloaded 352 times

Eric
Posts: 99
Joined: Tue Nov 06, 2007 11:04 pm
Been thanked: 1 time

Re: Int to Float

Post by Eric »

Thx Ben, now I see.
But the compiled program is hugh !
7.5K !
Floating point seems to consume a lot of resources.

Rgds,

Eric

Post Reply