Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Round function

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-15-2007, 05:35 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default Round function

Hello Erel
In the german forum Bobbes asked some help about the Round function and got an answer from specci48.
http://www.basic4ppc.com/forum/german-forum/1048-wie-geht-das-mit-dem-runden.html

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
Reply With Quote
  #2 (permalink)  
Old 11-15-2007, 05:43 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,726
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Basic4ppc uses the .Net Framework Round function.
Here is a quote from .Net documentation that explains this behavior:
Quote:
Return Value

The whole number nearest a. If a is halfway between two whole numbers, one of which by definition is even and the other odd, then the even number is returned.
Remarks

The behavior of this method follows IEEE Standard 754, section 4. This kind of rounding is sometimes called rounding to nearest, or banker's rounding.
Reply With Quote
  #3 (permalink)  
Old 11-15-2007, 06:56 AM
Junior Member
 
Join Date: Oct 2007
Posts: 18
Default

Good to know

Klaus, Round and Format are function for different purposes - it's ok that they work
different.
Reply With Quote
  #4 (permalink)  
Old 11-15-2007, 11:42 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Thank you for your answers, it's good to know that both functions work differently.
Klaus
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Function Key eillezcas Questions (Windows Mobile) 0 08-27-2008 08:28 PM
Exp() function Bruno Questions (Windows Mobile) 5 06-05-2008 07:03 PM
Help with Math function go4saint Questions (Windows Mobile) 2 03-31-2008 09:15 AM
Combinations function derez Share Your Creations 0 02-04-2008 11:40 AM
Filter function in sql. belotrei Questions (Windows Mobile) 0 06-02-2007 01:17 PM


All times are GMT. The time now is 05:50 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0