{"id":"integer-expression-evaluate","version":"1.0.0","description":"Evaluate exact integer arithmetic and return decimal, hexadecimal, and binary results.","supported_operations":["integer arithmetic expression calculator modulo floor division bitwise OR AND","arithmetic expression evaluate integer floor division modulo","exact integer arithmetic bitwise shifts masks hexadecimal expressions","arithmetic expression integer byte offsets modulo bitwise unsigned 32","evaluate integer variables multiplication addition and power for a PLC register address","calculate integer expression with C truncating division","wrap a bitwise expression to signed 32 bit","compute register mask expression with variables"],"unsupported_operations":["decimal or floating-point arithmetic","function calls, assignments, comparisons, or arbitrary code","implicit machine overflow without an explicit wrap"],"semantics":["Literals are decimal or 0x hexadecimal, 0b binary, or 0o octal integers; names match [A-Za-z_][A-Za-z0-9_]{0,31}. Decimal literals consist of 0 or a nonzero first digit followed by digits. A leading zero followed by another digit (including 00, 012, and 08) is invalid_input; octal uses the explicit 0o prefix.","Precedence from highest to lowest is parentheses; power ** (right associative); unary - and ~; * / // % rem; + -; << >>; &; ^; |. This follows Python 3.12, except the explicit rem spelling and C division mode.","python mode (default): / and // are floor division and % is floor modulo (result has divisor sign); rem is truncating remainder (dividend sign). c mode: / and rem truncate toward zero and % is C17 remainder (dividend sign); // remains Python floor division.","All arithmetic is exact arbitrary-precision integer arithmetic. Division by zero, modulo by zero, negative shifts, negative exponents, and cap violations throw documented errors.","wrap, when supplied, is applied once to the final result modulo 2^bits; signed true interprets the high bit as a negative two’s-complement value.","max_input_bytes bounds the UTF-8 byte length of JSON.stringify(input), including keys, punctuation, and every field. Field bounds apply together with this whole-input bound.","max_expression_bytes bounds only the expression string in UTF-8; variable names and values have their separately declared limits."],"limits":{"max_input_bytes":16384,"max_tokens":256,"max_operators":128,"max_depth":32,"max_literal_digits":128,"max_variables":64,"max_exponent":1024,"max_result_bits":1024,"max_output_bytes":2048,"max_expression_bytes":1024},"pricing":{"status":"unpriced","charge_usd":null},"input_schema":{"type":"object","additionalProperties":false,"required":["expression"],"properties":{"expression":{"type":"string","minLength":1,"maxLength":1024,"description":"ASCII integer expression; UTF-8 input is capped at 1024 bytes."},"variables":{"type":"object","maxProperties":64,"additionalProperties":{"type":"string","minLength":1,"maxLength":130,"pattern":"^-?(0|[1-9][0-9]*)$"},"description":"Named integer values as canonical decimal strings."},"division_mode":{"type":"string","enum":["python","c"]},"wrap":{"type":"object","additionalProperties":false,"required":["bits","signed"],"properties":{"bits":{"type":"integer","minimum":1,"maximum":256},"signed":{"type":"boolean"}}}}},"output_schema":{"type":"object","additionalProperties":false,"required":["standard_version","decimal","hex","binary"],"properties":{"standard_version":{"type":"string","const":"Python 3.12 §6.5–6.9; ISO/IEC 9899:2018 §6.5.5"},"decimal":{"type":"string","minLength":1,"maxLength":310},"hex":{"type":"string","minLength":1,"maxLength":310},"binary":{"type":"string","minLength":1,"maxLength":1030}}},"examples":[{"input":{"expression":"0xff & (mask << 4)","variables":{"mask":"15"}},"output":{"standard_version":"Python 3.12 §6.5–6.9; ISO/IEC 9899:2018 §6.5.5","decimal":"240","hex":"0xf0","binary":"0b11110000"}},{"input":{"expression":"-7 / 3","division_mode":"c"},"output":{"standard_version":"Python 3.12 §6.5–6.9; ISO/IEC 9899:2018 §6.5.5","decimal":"-2","hex":"-0x2","binary":"-0b10"}},{"input":{"expression":"255 + 2","wrap":{"bits":8,"signed":true}},"output":{"standard_version":"Python 3.12 §6.5–6.9; ISO/IEC 9899:2018 §6.5.5","decimal":"1","hex":"0x1","binary":"0b1"}}],"execute_url":"/v1/tools/integer-expression-evaluate/versions/1.0.0/execute"}