github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/parser/subtraction.md (about)

     1  # `-` Subtraction Operator
     2  
     3  > Subtracts one numeric value from another (expression)
     4  
     5  ## Description
     6  
     7  The Subtraction Operator takes the right hand number from the left hand number
     8  in an expression.
     9  
    10  
    11  
    12  ## Examples
    13  
    14  #### Expression
    15  
    16  ```
    17  » 3-2
    18  1
    19  ```
    20  
    21  #### Statement
    22  
    23  ```
    24  out (3-2)
    25  » 1
    26  ```
    27  
    28  ## Detail
    29  
    30  ### Type Safety
    31  
    32  Because shells are historically untyped, you cannot always guarantee that a
    33  numeric-looking value isn't a string. To solve this problem, by default Murex
    34  assumes anything that looks like a number is a number when performing addition.
    35  
    36  ```
    37  » str = "2"
    38  » int = 3
    39  » $str + $int
    40  1
    41  ```
    42  
    43  For occasions when type safety is more important than the convenience of silent
    44  data casting, you can disable the above behaviour via `config`:
    45  
    46  ```
    47  » config set proc strict-types false
    48  » $str + $int
    49  Error in `expr` (0,1): cannot Add with string types
    50                      > Expression: $str + $int
    51                      >           : ^
    52                      > Character : 1
    53                      > Symbol    : Scalar
    54                      > Value     : '$str'
    55  ```
    56  
    57  ## See Also
    58  
    59  * [`*` Multiplication Operator](../parser/multiplication.md):
    60    Multiplies one numeric value with another (expression)
    61  * [`+` Addition Operator](../parser/addition.md):
    62    Adds two numeric values together (expression)
    63  * [`-=` Subtract By Operator](../parser/subtract-by.md):
    64    Subtracts a variable by the right hand value (expression)
    65  * [`/` Division Operator](../parser/division.md):
    66    Divides one numeric value from another (expression)
    67  * [`cast`](../commands/cast.md):
    68    Alters the data type of the previous function without altering it's output
    69  * [`config`](../commands/config.md):
    70    Query or define Murex runtime settings
    71  * [`expr`](../commands/expr.md):
    72    Expressions: mathematical, string comparisons, logical operators
    73  * [`float` (floating point number)](../types/float.md):
    74    Floating point number (primitive)
    75  * [`int`](../types/int.md):
    76    Whole number (primitive)
    77  * [`num` (number)](../types/num.md):
    78    Floating point number (primitive)
    79  
    80  <hr/>
    81  
    82  This document was generated from [gen/expr/subtraction_op_doc.yaml](https://github.com/lmorg/murex/blob/master/gen/expr/subtraction_op_doc.yaml).