I can say this is the best way to do what you want, but I use the following:





* Print Int(100.559999 * 100) / 100.00 Print Round(100.559999, -2)*
The first operation truncates the number to 100.55 (no rounding takes
effect).
The second operation rounds the number to at most two digits after the
decimal separator.
This means in the example above, result will be 100.56. If the number was
100.59999
it would be rounded to 100.6.

Again, I dont know if those are the best way to do it, but it works.

Regards

-fernando



2017-07-13 2:39 GMT-03:00 alexchernoff <alexchern...@hotmail.com>:

> Peace to all,
>
> this might a bit silly but what is the best way to format float values like
> 26.6601666666666 into having two digits AND/OR  with rounding them?
>
> e.g.
>
> 26.6601666666666 becomes 26.66 shortened
> 26.6601666666666 becomes 26.67 rounded
>
> cheers!
>
>
>
>
>
> --
> View this message in context: http://gambas.8142.n7.nabble.
> com/Best-ways-to-format-float-values-tp59733.html
> Sent from the gambas-user mailing list archive at Nabble.com.
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



-- 
Fernando Cabral
Blogue: http://fernandocabral.org
Twitter: http://twitter.com/fjcabral
e-mail: fernandojosecab...@gmail.com
Facebook: f...@fcabral.com.br
Telegram: +55 (37) 99988-8868
Wickr ID: fernandocabral
WhatsApp: +55 (37) 99988-8868
Skype:  fernandojosecabral
Telefone fixo: +55 (37) 3521-2183
Telefone celular: +55 (37) 99988-8868

Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
nenhum político ou cientista poderá se gabar de nada.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to