Round function

klaus

Expert
Licensed User
Longtime User
Hello Erel
In the german forum Bobbes asked some help about the Round function and got an answer from specci48.
http://www.b4x.com/forum/showthread.php?t=1048

In his answer I wondered that the Round function works like
if > 5 then round up
else round down
Round(4.5,0) > 4

in my mind it should work like
if>=5 then round up
else round down
Round(4.5,0) > 5

as it does with the Format function.

I tried it in VisualBaisc it's the same.

Is there any reason for this behaviour.
I have joined a small example to show the difference.

Best regards
Klaus
Switzerland
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Basic4ppc uses the .Net Framework Round function.
Here is a quote from .Net documentation that explains this behavior:
 

Henry

Member
Licensed User
Good to know

Klaus, Round and Format are function for different purposes - it's ok that they work
different.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…