Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Monday, November 25, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: SLX Rounding Algorithim
Vaughn Poulson
Posts: 32
 
SLX Rounding AlgorithimYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Sep 16 1:42 PM

We are having trouble understanding which rounding algorithim is used in saleslogix so i tried an experiment.


Here is the code:



<p>Dim odd1, even1, even2, odd2

 


 odd2 = 1.255


 odd1 = 61.255


even1 = 2.255


even2 = 6.255


msgbox Round(odd2, 2) & vbCRLF & Round(odd1, 2) & vbCRLF & Round(even1, 2) & vbCRLF & Round(even2, 2)



And here is the result:


1.25


61.26


2.26


6.26


I can't figure out why the 1.255 gets rounded to 1.25 and all the others get rounded to .26.


we are on verson 8.1.

[Reply][Quote]
Steve Robertson
Posts: 146
 
Re: SLX Rounding AlgorithimYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Sep 16 4:29 AM

Saleslogix LAN is using VBScript, the round function is within VBScript. You can carry out the same test outside of Saleslogix in a vbs file and you will get the same results of 1.25, 61.26, 2.26 and 6.26.


This is sometimes referred to as Bankers' Rounding.


The following is from Microsoft https://msdn.microsoft.com/en-us/library/se6f2zfx(v=vs.84).aspx which should help explain the results.


"The Round function performs round to even, which is different from round to larger. The return value is the number closest to the value of expression, with the appropriate number of decimal places. If expression is exactly halfway between two possible rounded values, the function returns the possible rounded value whose rightmost digit is an even number. (In a round to larger function, a number that is halfway between two possible rounded values is always rounded to the larger number.)


Round to even is a statistically more accurate rounding algorithm than round to larger."

[Reply][Quote]
Vaughn Poulson
Posts: 32
 
Re: SLX Rounding AlgorithimYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Sep 16 7:41 AM

Thanks for the information.  I guess I'm still a little confused about when is says "the function returns the possible rounded value whose rightmost didgit is an even number"


With the two number 1.255 and 61.255 is the right most didgit the 1?


If so then both of them should have ended with .25, but in my case 1.255 returned 1.25 and 61.255 returned 61.26.

[Reply][Quote]
Steve Robertson
Posts: 146
 
Re: SLX Rounding AlgorithimYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Sep 16 8:35 AM

The following has much more on Rounding:


http://www.clivemaxfield.com/diycalculator/popup-m-round.shtml#A5


What you are seeing is rounding in VBScript - sometimes it rounds up and sometimes it rounds down, this is known as Round-Half-Even or Bankers Rounding.

[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/25/2024 5:15:49 PM