{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nLet $F \\subseteq \\R$ be unbounded above and below, with only finitely many elements in each bounded interval.\nAn example is the set $\\Z$ of [[integers|0C4JS9RF5M]].\nFor $x \\in \\R$ let $x^- = \\max \\set{f \\in F : f \\le x}$ and $x^+ = \\min \\set{f \\in F : f \\ge x}$.\nA *rounding* to $F$ is a map $\\mathrm{rd} \\colon \\R \\to F$ with $\\mathrm{rd}(x) \\in \\set{x^-, x^+}$ for every $x$.\nThe standard roundings are:\n\n1. *rounding down*: $\\mathrm{rd}(x) = x^-$;\n2. *rounding up*: $\\mathrm{rd}(x) = x^+$;\n3. *rounding toward zero*: $\\mathrm{rd}(x) = x^-$ if $x \\ge 0$ and $x^+$ if $x \u003c 0$;\n4. *rounding to nearest*: $\\mathrm{rd}(x)$ is the element of $\\set{x^-, x^+}$ closest to $x$. When $x$ is exactly halfway, a tie rule decides, such as *ties to even* or *ties away from zero*.\n\n## Remarks\n\nExample: for $F = \\Z$, rounding down is the [[floor function|08GR54CKEA]], rounding up is the ceiling function, and rounding to nearest with ties to even sends $2.5 \\mapsto 2$, $3.5 \\mapsto 4$ and $2.7 \\mapsto 3$.\nCheck for $2.7$: $x^- = 2$, $x^+ = 3$, and $\\abs{2.7 - 3} = 0.3 \u003c 0.7 = \\abs{2.7 - 2}$.\nNon-example: the map $x \\mapsto \\floor{x} - 1$ is not a rounding to $\\Z$, since $\\floor{2.7} - 1 = 1 \\notin \\set{2, 3}$.\nEach of the four standard roundings is monotone: $x \\le y$ implies $\\mathrm{rd}(x) \\le \\mathrm{rd}(y)$.\nAn arbitrary rounding need not be monotone, since it may choose $x^+$ for one point and $x^-$ for a larger point of the same gap.\nFor floating-point numbers, $F$ is extended by the subnormal numbers and by $\\pm \\infty$ to cover overflow.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "defines": "5NPVX29Y0C",
    "kind": "definition",
    "msc": [
      "65G50",
      "65Y04"
    ],
    "name": "Rounding",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Rounding"
      }
    ],
    "tag": "N6AFVYBY2Z",
    "uses": [
      "08GR54CKEA",
      "0C4JS9RF5M"
    ]
  },
  "kind": "definition",
  "link": "https://tamnd.github.io/math2/node/N6AFVYBY2Z/",
  "links": [
    {
      "field": "defines",
      "target": "5NPVX29Y0C"
    },
    {
      "field": "uses",
      "target": "08GR54CKEA"
    },
    {
      "field": "uses",
      "target": "0C4JS9RF5M"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/N6AFVYBY2Z.md",
  "msc": [
    "65G50",
    "65Y04"
  ],
  "name": "Rounding",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/N6A/N6AFVYBY2Z.md",
  "status": null,
  "tag": "N6AFVYBY2Z",
  "uri": "m2://N6AFVYBY2Z",
  "url": "https://tamnd.github.io/math2/wiki/rounding-definition/",
  "writing": {
    "tag": "N6AFVYBY2Z",
    "kind": "definition",
    "level": "W0",
    "next": [
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
