Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Round function


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

Hello Erel
In the german forum Bobbes asked some help about the Round function and got an answer from specci48.
wie geht das mit dem runden ???

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
Attached Files
File Type: sbp TestRound.sbp (1.4 KB, 4 views)
Reply With Quote
  #2 (permalink)  
Old 11-15-2007, 06:43 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,199
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, 07: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, 12:42 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Switzerland
Posts: 707
Awards Showcase
Beta Tester Competition Winner 
Total Awards: 2
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 On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 06:27 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0