{"title":"Arithmetic operators","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-al-arithmetic-operators/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-al-arithmetic-operators, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-al-arithmetic-operators","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Description of the arithmetic operators in AL for Business Central.","date":"2024-07-01","meta":{"topic":"concept-article"},"outline":[{"level":2,"title":"Unary arithmetic operators","slug":"unary-arithmetic-operators","at":217,"chars":382},{"level":2,"title":"Binary arithmetic operators","slug":"binary-arithmetic-operators","at":599,"chars":1884},{"level":3,"title":"Definition of type conversion rules for the `+` operator","slug":"definition-of-type-conversion-rules-for-the-operator","at":1554,"chars":929},{"level":2,"title":"Example 1","slug":"example-1","at":2483,"chars":292},{"level":2,"title":"Example 2","slug":"example-2","at":2775,"chars":287},{"level":2,"title":"Related information","slug":"related-information","at":3062,"chars":101}],"text":"This article shows how to use type conversion rules for arithmetic operators in AL. The examples demonstrate operator usage and the effect of type conversion by the AL compiler. Examples are grouped by AL data types.\n## Unary arithmetic operators\nThe unary arithmetic operators in AL are prefix operators with the following syntax.\n```\nPrefixExpression = PrefixOperator Expression\n```\nThe following table shows the data types for which the unary operators in AL are defined, and the resulting data types.\nUnary operator|Option|Integer|Decimal\n`+`|integer|integer|decimal\n`-`|integer|integer|decimal\n## Binary arithmetic operators\nThe following table shows the data types for which the binary arithmetic operators are defined. The binary arithmetic operators in AL are all infix operators.\n```\nInfixExpression = LeftExpression InfixOperator RightExpression\n```\nOperator|Boolean|Byte|Char|Option|Integer|Decimal|Date|Time|Text|Code\n--|--|--|--|------------|-------------|-------------|----------|----------|----------|----------\n`+`|No|Yes|Yes|Yes|Yes|Yes|Yes|Yes|Yes|Yes\n`-`|No|Yes|Yes|Yes|Yes|Yes|Yes|Yes|No|No\n`*`|No|Yes|Yes|Yes|Yes|Yes|No|No|No|No\n`/`|No|Yes|Yes|Yes|Yes|Yes|No|No|No|No\nDIV|No|Yes|Yes|Yes|Yes|Yes|No|No|No|No\nMOD|No|Yes|Yes|Yes|Yes|Yes|No|No|No|No\nIn the table, Yes means that the operator can take at least one operand \\(left, right, or both\\) of the given type; No means that the operator can't be used with the given type.\nThe following table defines the valid uses of the binary arithmetic operators, and the resulting data types.\n### Definition of type conversion rules for the `+` operator\n|The `+` operator|Boolean|Byte/Char|Option|Integer|Decimal|Date|Time|Text|Code|\n|----------------|--|--|--|--|--|----------|----------|----------|----------|\n|Boolean||||||||||\n|Byte/Char||Integer|Integer \\(C\\)|Integer \\(C\\)|Decimal \\(C\\)|||||\n|Option||Integer|Integer \\(C\\)|Integer \\(C\\)|Decimal \\(C\\)|||||\n|Integer||Integer \\(C\\)|Integer \\(C\\)|Integer \\(C\\)|Decimal \\(C\\)|||||\n|Decimal||Decimal \\(C\\)|Decimal \\(C\\)|Decimal \\(C\\)|Decimal \\(C\\)|||||\n|Date||Date \\(A\\) \\(C\\)|Date \\(A\\) \\(C\\)|Date \\(A\\) \\(C\\)|Date \\(A\\) \\(C\\) \\(D\\)|||||\n|Time||Time\\(B\\) \\(C\\)|Time\\(B\\) \\(C\\)|Time\\(B\\) \\(C\\)|Time\\(B\\) \\(C\\) \\(D\\)|||||\n|Text||||||||Text|Text|\n|Code||||||||Text|Code|\n\\(A\\) The operation isn't defined for the Date 0D.\n\\(B\\) The operation isn't defined for the Time 0T.\n\\(C\\) Overflow might occur.\n\\(D\\) The operation isn't defined if the Decimal has a fractional part.\n## Example 1\nThis table illustrates type conversion in integer operator expressions.\nOperator|Name|Expression|Resulting data type\n`+`|Time addition|Time + Integer|Time\n`-`|Time difference|Time - Time|Integer\nThe time unit is milliseconds. If time is undefined \\(0T\\), a runtime error occurs.\n## Example 2\nThis table illustrates type conversion in text and code \\(String\\) operator expressions.\nOperator|Name|Expression|Resulting data type\n`+`|Concatenation|Text + Text|Text\n`+`|Concatenation|Text + Code|Text\n`+`|Concatenation|Code + Text|Text\n`+`|Concatenation|Code + Code|Code\n## Related information\ndevenv-al-operators\ndevenv-al-boolean-operators\ndevenv-al-relational-operators"}