Page 1 of 1
Rounding a Float
Posted: Mon Dec 27, 2021 11:24 pm
by MJU20
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.
Re: Rounding a Float
Posted: Tue Dec 28, 2021 1:01 am
by medelec35
The easiest way to round to one decimal place for example is
Code: Select all
StringVar = FloatToString$ (FloatVar,1)
It will also round up to the nearest decimal place.
I'm sure that works well.
Re: Rounding a Float
Posted: Wed Dec 29, 2021 10:58 am
by Steve-Matrix
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.