{"id":"decimal-round","version":"1.0.0","description":"Round a decimal string with an explicit mode to fraction digits, significant digits or a multiple of an increment.","supported_operations":["round a decimal half even","round to 2 decimal places","round to significant figures","round to the nearest 0.05","swiss cash rounding to 5 rappen","bankers rounding of a number","round half up versus half down","round toward zero, up or down to n digits"],"unsupported_operations":["rounding floating point or scientific notation input","rounding the results of formulas or lists","currency specific rounding rules by country","formatting with thousands separators or symbols"],"semantics":["Decimal strings match ^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$: no plus sign, exponent, leading zeros, leading or trailing point, whitespace or separators. A JSON number where a decimal string is required is invalid_input (wrong type).","A decimal string longer than 62 UTF-16 code units -> limit_exceeded, checked before the grammar. Otherwise a grammar failure, more than 60 digits in total, or more than 40 fraction digits -> invalid_input.","Zero has no sign: \"-0\", \"-0.00\" and any all-zero value are zero and are emitted as \"0\" (canonical) or \"0.00\" (fixed scale), never \"-0\".","Exactly one of scale, significant_digits, increment must be present; none or more than one -> invalid_input. scale is an integer 0..40, significant_digits an integer 1..60.","Rounding modes act on the exact rational result and are: half_even (ties to the even neighbour), half_up (ties away from zero), half_down (ties toward zero), half_ceiling (ties toward +infinity), half_floor (ties toward -infinity), up (away from zero), down (toward zero), ceiling (toward +infinity), floor (toward -infinity), unnecessary (any inexact result -> not_computable with details.reason \"rounding_necessary\").","scale target: round value to scale fraction digits; output has exactly scale fraction digits (\"217\" at scale 1 -> \"217.0\"; \"2.17\" at scale 3 -> \"2.170\").","increment target: the increment must be a decimal > 0 (zero or negative -> invalid_input). Result = k * increment where k = round(value / increment) using the mode on the exact quotient. The output scale is the number of fraction digits written in the increment string (\"0.05\" -> 2 digits, \"1.00\" -> 2 digits, \"5\" -> 0), so \"3\" rounded to increment \"1.00\" is \"3.00\". Ties are decided on the quotient: 1.025 with increment 0.05 is quotient 20.5, half_even -> 20 -> \"1.00\", half_up -> 21 -> \"1.05\".","significant_digits target with d digits, for value x != 0: e = floor(log10|x|) of the exact value; round x to a multiple of 10^(e-d+1) with the mode; the output scale is max(0, d-1-e), so trailing zeros are kept (1.5 to 5 digits -> \"1.5000\"; 123456 to 2 digits -> \"120000\"). If rounding carries into the next power of ten (|result| >= 10^(e+1)) the output scale is one less, floored at 0 (9.995 to 3 digits half_up -> \"10.0\"; 999.5 to 3 digits half_up -> \"1000\"). A zero value gives \"0\" with scale 0 and exact true.","exact is true iff the rounded value equals the input value. The output field scale reports the fraction digits of value; target reports which target was used.","rounding \"unnecessary\" with an inexact result -> not_computable with details.reason \"rounding_necessary\".","Validation order (each vector carries a single fault): input not an object; unknown field; missing required field; field types, ranges and decimal-string limits; scale/rounding pairing; then domain errors (not_computable) last."],"limits":{"max_decimal_chars":62,"max_decimal_digits":60,"max_fraction_digits":40,"max_scale":40,"max_significant_digits":60},"pricing":{"status":"unpriced","charge_usd":null},"input_schema":{"type":"object","additionalProperties":false,"required":["value","rounding"],"properties":{"value":{"type":"string","minLength":1,"maxLength":62,"pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Decimal string to round."},"rounding":{"type":"string","enum":["half_even","half_up","half_down","half_ceiling","half_floor","up","down","ceiling","floor","unnecessary"],"description":"Rounding mode."},"scale":{"type":"integer","minimum":0,"maximum":40,"description":"Target: round to this many fraction digits. Give exactly one of scale, significant_digits, increment."},"significant_digits":{"type":"integer","minimum":1,"maximum":60,"description":"Target: round to this many significant digits."},"increment":{"type":"string","minLength":1,"maxLength":62,"pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Target: round to the nearest multiple of this positive decimal."}}},"output_schema":{"type":"object","additionalProperties":false,"required":["value","exact","target","scale"],"properties":{"value":{"type":"string","minLength":1,"maxLength":160,"description":"Rounded value written with exactly the output scale fraction digits."},"exact":{"type":"boolean","description":"true when the rounded value equals the input value."},"target":{"type":"string","enum":["scale","significant_digits","increment"],"description":"Which target was used."},"scale":{"type":"integer","minimum":0,"maximum":100,"description":"Number of fraction digits in value."}}},"examples":[{"input":{"value":"2.675","rounding":"half_even","scale":2},"output":{"value":"2.68","exact":false,"target":"scale","scale":2}},{"input":{"value":"1.025","rounding":"half_up","increment":"0.05"},"output":{"value":"1.05","exact":false,"target":"increment","scale":2}},{"input":{"value":"123456","rounding":"half_up","significant_digits":2},"output":{"value":"120000","exact":false,"target":"significant_digits","scale":0}}],"execute_url":"/v1/tools/decimal-round/versions/1.0.0/execute"}