lib/standard/math: Added binops aliases for Int
[nit.git] / lib / standard / math.nit
index 8b5fecb..d503b43 100644 (file)
@@ -29,21 +29,33 @@ redef class Int
        #     assert 0x10.bin_and(0x01) == 0
        fun bin_and(i: Int): Int is extern "kernel_Int_Int_binand_0"
 
+       # Alias of `bin_and`
+       fun &(i: Int): Int do return bin_and(i)
+
        # Returns the result of a binary OR operation on `self` and `i`
        #
        #     assert 0x10.bin_or(0x01) == 0x11
        fun bin_or(i: Int): Int is extern "kernel_Int_Int_binor_0"
 
+       # Alias of `bin_or`
+       fun |(i: Int): Int do return bin_or(i)
+
        # Returns the result of a binary XOR operation on `self` and `i`
        #
        #     assert 0x101.bin_xor(0x110) == 0x11
        fun bin_xor(i: Int): Int is extern "kernel_Int_Int_binxor_0"
 
+       # Alias of `bin_xor`
+       fun ^(i: Int): Int do return bin_xor(i)
+
        # Returns the 1's complement of `self`
        #
        #     assert 0x2F.bin_not == -48
        fun bin_not: Int is extern "kernel_Int_Int_binnot_0"
 
+       # Alias of `bin_not`
+       fun ~: Int do return bin_not
+
        # Returns the square root of `self`
        #
        #     assert 16.sqrt == 4