Rounding String or Float Variables

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8378
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2384 times
Been thanked: 3416 times
Contact:

Rounding String or Float Variables

Postby medelec35 » Tue Nov 27, 2012 11:05 pm

I though I would develop a different way to round off a float variable.
Using pot you can select number of decimal places (0 to 6)
Rounding  off.png
Rounding off.png (21.54 KiB) Viewed 2901 times

Decimal numbers are basically cut off, and not rounded up or down.
E.g 1.29 to 1dp = 1.2 and not 1.3

Martin

Edit: Temp2 with original flowchart is not required, so it's fine just to delete it.
I have updated flowchart with Temp2 removed.
Attachments
Rounding Float Or String Numbers.fcf
(12.67 KiB) Downloaded 257 times
These users thanked the author medelec35 for the post (total 4):
brandonb (Tue Nov 27, 2012 11:35 pm) • Benj (Wed Nov 28, 2012 12:10 pm) • Steven_SS (Mon Dec 03, 2018 9:09 pm) • jgu1 (Tue Dec 04, 2018 4:47 pm)
Rating: 21.05%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8378
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2384 times
Been thanked: 3416 times
Contact:

Re: Rounding String or Float Variables

Postby medelec35 » Mon Dec 03, 2018 9:35 pm

Hi Steven,
Steven_SS wrote:
medelec35 wrote:I though I would develop a different way to round off a float variable.
Using pot you can select number of decimal places (0 to 6)
Rounding off.png
Decimal numbers are basically cut off, and not rounded up or down.
E.g 1.29 to 1dp = 1.2 and not 1.3
Martin


How can I open this in flowcode V8 Martin? Thanks



Sorry you can't now, take a look at this post
I'm happy to convert any flowcharts for anyone from any version to version 8.

Edit:
Although you have figured it out and now deleted your post, I will leave this post for anyone else who has V8
Attachments
Rounding Float Or String Numbers.fcfx
(13.63 KiB) Downloaded 72 times
Last edited by medelec35 on Mon Dec 03, 2018 9:37 pm, edited 1 time in total.
These users thanked the author medelec35 for the post (total 3):
Benj (Mon Dec 03, 2018 10:13 pm) • Steven_SS (Mon Dec 03, 2018 10:17 pm) • jgu1 (Tue Dec 04, 2018 4:47 pm)
Rating: 15.79%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

Re: Rounding String or Float Variables

Postby jadiflow » Thu May 09, 2019 3:14 pm

Can I add my vote that someone fixes this? fround(x,y) doesn't work, instead it work like round(). The floating point number is rounded to the next integer instead of actually rounded up.

If it can't be fixed, maybe indicate in the help file that it doesn't work for PIC processors.

Jan Didden
Linear Audio