Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Rounding
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Directed rounding to an integer=== These four methods are called '''directed rounding to an integer''', as the displacements from the original number {{mvar|x}} to the rounded value {{mvar|y}} are all directed toward or away from the same limiting value (0, [[extended real number line|+β]], or ββ). Directed rounding is used in [[interval arithmetic]] and is often required in financial calculations. If {{mvar|x}} is positive, round-down is the same as round-toward-zero, and round-up is the same as round-away-from-zero. If {{mvar|x}} is negative, round-down is the same as round-away-from-zero, and round-up is the same as round-toward-zero. In any case, if {{mvar|x}} is an integer, {{mvar|y}} is just {{mvar|x}}. Where many calculations are done in sequence, the choice of rounding method can have a very significant effect on the result. A famous instance involved a new [[stock index|index]] set up by the [[Vancouver Stock Exchange]] in 1982. It was initially set at 1000.000 (three decimal places of accuracy), and after 22 months had fallen to about 520, although the market appeared to be rising. The problem was caused by the index being recalculated thousands of times daily, and always being truncated (rounded down) to 3 decimal places, in such a way that the rounding errors accumulated. Recalculating the index for the same period using rounding to the nearest thousandth rather than truncation corrected the index value from 524.811 up to 1098.892.<ref> {{cite book |title=Accuracy and stability of numerical algorithms |author-first=Nicholas John |author-last=Higham |author-link=Nicholas Higham |page=54 |isbn=978-0-89871-521-7 |date=2002| url=https://books.google.com/books?id=7J52J4GrsJkC&dq=vancouver+stock+exchange+rounding&pg=PA54 |doi=10.1137/1.9780898718027.ch2 |edition=2nd |url-access=limited}} {{pb}} {{cite journal |last=Nievergelt |first=Yves |year=2000 |title=Rounding Errors to Knock Your Stocks Off |journal=Mathematics Magazine |volume=73 |issue=1 |pages=47β48 |doi=10.1080/0025570X.2000.11996800 |jstor=2691491 }} {{pb}} {{cite news |last=Quinn |first=Kevin |title=Ever had problems rounding off figures? This stock exchange has |newspaper=Wall Street Journal |date=8 November 1983 |url=https://www5.in.tum.de/~huckle/Vancouv.pdf}} {{pb}} {{cite news |last=Lilley |first=Wayne |newspaper=The Toronto Star |date=November 29, 1983 |title=Vancouver stock index has right number at last |url=https://www5.in.tum.de/~huckle/Vancouv.pdf }} </ref> For the examples below, {{math|sgn(''x'')}} refers to the [[sign function]] applied to the original number, {{mvar|x}}. ====Rounding down==== One may '''round down''' (or take the '''[[floor and ceiling functions|floor]]''', or '''round toward negative infinity'''): {{mvar|y}} is the largest integer that does not exceed {{mvar|x}}. : <math>y = \mathrm{floor}(x) = \left\lfloor x \right\rfloor = -\left\lceil -x \right\rceil</math> For example, 23.7 gets rounded to 23, and β23.2 gets rounded to β24. ====Rounding up==== One may also '''round up''' (or take the '''[[floor and ceiling functions|ceiling]]''', or '''round toward positive infinity'''): {{mvar|y}} is the smallest integer that is not less than {{mvar|x}}. : <math>y = \operatorname{ceil}(x) = \left\lceil x \right\rceil = -\left\lfloor -x \right\rfloor</math> For example, 23.2 gets rounded to 24, and β23.7 gets rounded to β23. ====Rounding toward zero==== One may also '''round toward zero''' (or '''[[truncation|truncate]]''', or '''round away from infinity'''): {{mvar|y}} is the integer that is closest to {{mvar|x}} such that it is between 0 and {{mvar|x}} (included); i.e. {{mvar|y}} is the integer part of {{mvar|x}}, without its fraction digits. : <math> y = \operatorname{truncate}(x) = \sgn(x) \left\lfloor \left| x \right| \right\rfloor = -\sgn(x) \left\lceil -\left| x \right| \right\rceil = \begin{cases} \left\lfloor x \right\rfloor & x \ge 0 \\[5mu] \left\lceil x \right\rceil & x < 0 \end{cases} </math> For example, 23.7 gets rounded to 23, and β23.7 gets rounded to β23. ====Rounding away from zero==== One may also '''round away from zero''' (or '''round toward infinity'''): {{mvar|y}} is the integer that is closest to 0 (or equivalently, to {{mvar|x}}) such that {{mvar|x}} is between 0 and {{mvar|y}} (included). : <math> y = \sgn(x) \left\lceil \left| x \right| \right\rceil = -\sgn(x) \left\lfloor -\left| x \right| \right\rfloor = \begin{cases} \left\lceil x \right\rceil & x \ge 0 \\[5mu] \left\lfloor x \right\rfloor & x < 0 \end{cases} </math> For example, 23.2 gets rounded to 24, and β23.2 gets rounded to β24.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Rounding
(section)
Add topic