# Math/Float Question

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
• Hey,

I'm working on a small program that has a couple global values that are floats.
I need to isolate the number before the decimal from the numbers behind the decimal.

The only solution that I've come up with is:
Parse the float to a string, use Mid\$ to isolate, parse the string back to a value..

I'm curious if there is a way to handle such a task without having to parse the float to a string?

• T̶r̶y̶ ̶r̶o̶u̶n̶d̶(̶)̶.̶

Nevermind that. BossRighteous has a much better solution.

• floor() would be better suited since it essentially drops anything past the decimal, round would alter the number upward if the decimal portion is >=.5

Do you also need to grab the the decimal portion as a separate number?

• hey, whaddya know?! I learned what floor() is today.

I came back because I modified my original example to account for the rounding upward: I multiplied the number by 10 before rounding and than divided by 10. LOL! floor() is certainly a better way to go. Thanks, Boss!

• There is also a ceiling() which rounds up any decimal >.0

To clarify:

I actually need to isolate and store both numbers separately.

For example, lets say the Global Value is 4.7, I need the 4 and I need the 7.

Thanks!

• This really only works if you have a significant figure (number of decimal places of accuracy) in mind.

Attached is an example that pulls the first portion into a counter, and also pulls the second portion up to a defined amount of digits.

*10 would be 1 digit of decimal, *10000 would be 4 and so on

You'll notice that the counter rounds up the first assignment, but the value traces out right in the debug panel as an actual value.

Doh! In the Counter properties there is a significant figure checkbox, so check that and the rounding wont occur on assignment to the counter. Anyway, you get the idea.

• floor((X - Floor(x))*1000) is awesome.

BossRighteous is a Boss... Watch out Rick Ross..

• Not sure which one is faster, but if you want to split it into two strings, you can use the Find() expression to do this.

This will get the digits following the decimal point:

Mid\$(Str\$(Alterable Value A( "Active" ) ), Find(Str\$(Alterable Value A( "Active" ) ), ".", 0 ) + 1, Len(Str\$(Alterable Value A( "Active" ))))

And this should get the digits before the decimal point:

Left\$(Str\$(Alterable Value A( "Active" ) ), Find(Str\$(Alterable Value A( "Active" ) ), ".", 0 ) )

## Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!