{
  "name": "Tie-breaking and rounding direction of MATLAB, Octave and NumPy rounding functions",
  "description": "Compares how documented rounding functions treat exact halves and direction, compiled from the official MATLAB, GNU Octave and NumPy documentation pages, with the documented example inputs and outputs.",
  "page": "https://casrai.org/guides/matlab-round",
  "publisher": "CASRAI",
  "license": "https://creativecommons.org/licenses/by/4.0/",
  "dateModified": "2026-11-23T14:00:00Z",
  "temporalCoverage": "2026",
  "spatialCoverage": null,
  "columns": [
    {
      "name": "Function or setting",
      "unit": "",
      "description": ""
    },
    {
      "name": "Tool",
      "unit": "",
      "description": ""
    },
    {
      "name": "Rule",
      "unit": "",
      "description": ""
    },
    {
      "name": "Documented example",
      "unit": "",
      "description": ""
    }
  ],
  "rows": [
    {
      "Function or setting": "round (default, TieBreaker fromzero)",
      "Tool": "MATLAB",
      "Rule": "Nearest integer; ties away from zero",
      "Documented example": "-2.5:1:2.5 gives -3 -2 -1 1 2 3"
    },
    {
      "Function or setting": "round with TieBreaker=even",
      "Tool": "MATLAB",
      "Rule": "Nearest integer; ties to even",
      "Documented example": "-2.5:1:2.5 gives -2 -2 0 0 2 2"
    },
    {
      "Function or setting": "fix",
      "Tool": "MATLAB",
      "Rule": "Toward zero",
      "Documented example": "[-1.9 -3.4; 1.6 2.5; -4.5 4.5] gives [-1 -3; 1 2; -4 4]"
    },
    {
      "Function or setting": "round",
      "Tool": "GNU Octave",
      "Rule": "Nearest integer; ties further from zero",
      "Documented example": "round([-2.7,2.7]) gives -3 3; 2.5 gives 3"
    },
    {
      "Function or setting": "roundb",
      "Tool": "GNU Octave",
      "Rule": "Nearest integer; ties to even",
      "Documented example": "Banker's rounding"
    },
    {
      "Function or setting": "numpy.round",
      "Tool": "NumPy",
      "Rule": "Ties to nearest even value",
      "Documented example": "[.5,1.5,2.5,3.5,4.5] gives [0,2,2,4,4]"
    }
  ],
  "sources": [
    {
      "title": "MATLAB round",
      "url": "https://www.mathworks.com/help/matlab/ref/double.round.html",
      "accessed": "2026-11-12"
    },
    {
      "title": "MATLAB fix",
      "url": "https://www.mathworks.com/help/matlab/ref/double.fix.html",
      "accessed": "2026-11-12"
    },
    {
      "title": "GNU Octave Utility Functions",
      "url": "https://docs.octave.org/latest/Utility-Functions.html",
      "accessed": "2026-11-12"
    },
    {
      "title": "numpy.round",
      "url": "https://numpy.org/doc/stable/reference/generated/numpy.round.html",
      "accessed": "2026-11-12"
    }
  ]
}