[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gambas-user] rounding a half


Interesting... this is a floating point presentation problem. Should be
fixable.
It is due to the internally used floor. And the problem occurs in Gambas as
well:

Print (1.055 / 0.01 + 0.5);; Floor((1.055 / 0.01 + 0.5))
106 105


Jussi


On Mon, Dec 9, 2024 at 2:19 PM wig <wig@xxxxxxxxx> wrote:

>
>
> I would think that rounding a half would always react the same, either
> up or down;
>
> f = 1.015
>
> Print "Round(" & f & ", -2) = " & Round(f, -2)
>
> Result:
>
> Round(1.015, -2) = 1.02
>
> f = 1.055
>
> Print "Round(" & f & ", -2) = " & Round(f, -2)
>
> Round(1.055, -2) = 1.05
>
> What should I expect?
>
> I used Gambas 3.18.4
>
> System info see attach
>
> Kind greetings,
>
> Wig
>
>  _______________________________________________
> Gambas-user mailing list
> Gambas-user@xxxxxxxxxxxxxxxxxxxxx
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>

Follow-Ups:
Re: [Gambas-user] rounding a halfJussi Lahtinen <jussi.lahtinen@xxxxxxxxx>