In this topic: https://www.matrixtsl.com/mmforums/view ... 794#p95329 someone asked how to round a Float to a certain amount of decimals.
This isn't fixed yet?
If I round a float to 1 decimal and then convert it to a string, I still get 6 decimals.
Rounding a Float
-
- Posts: 243
- http://meble-kuchenne.info.pl
- Joined: Tue Dec 08, 2020 5:11 pm
- Has thanked: 75 times
- Been thanked: 50 times
-
- Matrix Staff
- Posts: 1450
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 509 times
- Been thanked: 472 times
Re: Rounding a Float
The easiest way to round to one decimal place for example is
It will also round up to the nearest decimal place.
I'm sure that works well.
Code: Select all
StringVar = FloatToString$ (FloatVar,1)
I'm sure that works well.
Martin
-
- Matrix Staff
- Posts: 1249
- Joined: Sat Dec 05, 2020 10:32 am
- Has thanked: 167 times
- Been thanked: 277 times
Re: Rounding a Float
It is also relatively easy to work around by first multiplying (or dividing) by 1000 (or whatever factor you want), then rounding to the nearest integer, and then dividing (or multiplying) by the same factor.