mendix / docs

Mendix documentation repository
https://docs.mendix.com
Creative Commons Attribution 4.0 International
139 stars 716 forks source link

Wrong documentation for the round() function #373

Closed dan-covaliu closed 7 years ago

dan-covaliu commented 7 years ago

The doc states that the round is using banker's rounding. However logging the following statements: toString(round(23.5)) + ' ' + toString(round(-23.5)) + ' ' + toString(round(24.5)) + ' ' + toString(round(-24.5)) + ' ' + toString(round(22.5)) + ' ' + toString(round(-22.5)) + ' ' + toString(round(21.5)) + ' ' + toString(round(-21.5)) obtains: 24,-24,25,-25,23,-23,22,-22, which looks more like "half away from zero" rounding, also called commercial rounding (https://en.wikipedia.org/wiki/Rounding#Round_half_away_from_zero).

Rvthof commented 7 years ago

Hi Dan,

There is an option in your Settings where you can switch between these two. Can you check if that's set correctly?

It is maybe a good idea to add this to the docs for the round function, to make this more clear.

image

Adam-Dupaski commented 7 years ago

Documentation updated: https://docs.mendix.com/refguide/mathematical-function-calls#output-2

Closing issue.

dan-covaliu commented 7 years ago

Hi Adam,

I knew about the setting… Thank you for making the documentation more precise. Still, I detect an error in the banker’s rounding definition. These are tests conducted using each setting, in turn:

Half away from zero: toString(round(200000 div 72,2)): 2777.78 toString(round(2777.775, 2)): 2777.78 toString(round(88.725, 2)): 88.73 toString(round(23.5)): 24 toString(round(-23.5)): -24 toString(round(24.5)): 25 toString(round(-24.5)): -25 toString(round(22.5)): 23 toString(round(-22.5)): -23 toString(round(21.5)): 22 toString(round(-21.5)): -22

Half to the nearest EVEN number: toString(round(200000 div 72,2)): 2777.78 toString(round(2777.775, 2)): 2777.78 toString(round(88.725, 2)): 88.72 toString(round(23.5)): 24 toString(round(-23.5)): -24 toString(round(24.5)): 24 toString(round(-24.5)): -24 toString(round(22.5)): 22 toString(round(-22.5)): -22 toString(round(21.5)): 22 toString(round(-21.5)): -22

As you can see EVEN numbers are 22,-22, 24 and -24, not 23 and -23

Regards, | Cordialement,

Dan Covaliu Software Integrator and Designer | Intégrateur et concepteur de logiciel T 514-496-1479 F 514-496-9344

bdc.cahttp://www.bdc.ca/EN/Pages/home.aspx?utm_campaign=signature&utm_medium=email&utm_source=signature

From: Adam Dupaski [mailto:notifications@github.com] Sent: June 19, 2017 4:32 AM To: mendix/docs docs@noreply.github.com Cc: COVALIU, Dan (MTL) Dan.Covaliu@bdc.ca; Author author@noreply.github.com Subject: Re: [mendix/docs] Wrong documentation for the round() function (#373)

Documentation updated: https://docs.mendix.com/refguide/mathematical-function-calls#output-2

Closing issue.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/mendix/docs/issues/373#issuecomment-309373977, or mute the threadhttps://github.com/notifications/unsubscribe-auth/APTduqWi5LRa2tZrw8Va7_LvE_b3JXT-ks5sFjIVgaJpZM4NRD3J.


Confidentiality Warning: This message and any attachments are intended only for the use of the intended recipient(s), are confidential, and may be privileged. If you are not the intended recipient, you are hereby notified that any review, retransmission, conversion to hard copy, copying, circulation or other use of this message and any attachments is strictly prohibited. If you are not the intended recipient, please notify the sender immediately by return email, and delete this message and any attachments from your system. Thank-you!

Information confidentielle: Le présent message, ainsi que tout fichier qui y est joint, est (sont) envoyé(s) à l'intention exclusive de son ou (ses) destinataire(s); il est de nature confidentielle et peut faire l'objet d'une information privilégiée. Nous avisons toute personne autre que le destinataire prévu que tout examen, réacheminement, impression, copie, distribution ou toute autre utilisation de ce message et tout document joint est (sont) strictement interdit(s). Si vous n'êtes pas le destinataire prévu, veuillez en aviser immédiatement l'expéditeur par retour de courriel et supprimer ce message et tout document joint de votre système. Merci!

Adam-Dupaski commented 7 years ago

Hi Dan, Thanks for the message. I've clarified the example in the documentation: https://docs.mendix.com/refguide/mathematical-function-calls#output-2 Cheers.

Adam-Dupaski commented 7 years ago

Hi Dan, one more thing: please note that you can contribute to the Mendix documentation yourself by sending a pull request with any changes/suggestions. See here for more details!