Arithmetic/Integer: Difference between revisions
Content added Content deleted
(Added LFE example) |
No edit summary |
||
Line 1,701: | Line 1,701: | ||
Note that <code>div</code> doesn't always do integer division; it performs the operation "most appropriate to the |
Note that <code>div</code> doesn't always do integer division; it performs the operation "most appropriate to the |
||
operand types". [http://perlcabal.org/syn/S03.html#line_729 Synopsis 3] guarantees that <code>div</code> "on built-in integer types is equivalent to taking the floor of a real division". If you want integer division with other types, say <code>floor($a/$b)</code>. |
operand types". [http://perlcabal.org/syn/S03.html#line_729 Synopsis 3] guarantees that <code>div</code> "on built-in integer types is equivalent to taking the floor of a real division". If you want integer division with other types, say <code>floor($a/$b)</code>. |
||
=={{header|PHL}}== |
|||
<lang phl>module arith; |
|||
extern printf; |
|||
extern scanf; |
|||
@Integer main [ |
|||
@Pointer<@Integer> a = alloc(4); |
|||
@Pointer<@Integer> b = alloc(4); |
|||
scanf("%i %i", a, b); |
|||
printf("a + b = %i\n", a::get + b::get); |
|||
printf("a - b = %i\n", a::get - b::get); |
|||
printf("a * b = %i\n", a::get * b::get); |
|||
printf("a / b = %i\n", a::get / b::get); |
|||
printf("a % b = %i\n", a::get % b::get); |
|||
printf("a ** b = %i\n", a::get ** b::get); |
|||
return 0; |
|||
]</lang> |
|||
=={{header|PHP}}== |
=={{header|PHP}}== |