Real constants and functions: Difference between revisions
Content added Content deleted
(→{{header|Elm}}: Add, referencing http://package.elm-lang.org/packages/elm-lang/core/3.0.0/Basics) |
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: Add tau, mention method forms, expand explanation a bit) |
||
Line 1,423: | Line 1,423: | ||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |
||
<lang perl6>say e; # e |
<lang perl6>say e; # e |
||
say |
say π; # or pi # pi |
||
say |
say τ; # or tau # tau |
||
# Common mathmatical function are availble |
|||
# as subroutines and as numeric methods. |
|||
# It is a matter of personal taste and |
|||
# programming style as to which is used. |
|||
say sqrt 2; # Square root |
say sqrt 2; # Square root |
||
say 2.sqrt; # Square root |
|||
# If you omit a base, does natural logarithm |
|||
say log 2; # Natural logarithm |
say log 2; # Natural logarithm |
||
say |
say 2.log; # Natural logarithm |
||
# Specify a base if other than e |
|||
say log 4, 10; # Base 10 logarithm |
|||
say 4.log(10); # Base 10 logarithm |
|||
say 4.log10; # Convenience, base 10 only logarithm |
|||
say exp 7; # Exponentiation base e |
|||
say 7.exp; # Exponentiation base e |
|||
# Specify a base if other than e |
|||
say exp 7, 4; # Exponentiation |
|||
say 7.exp(4); # Exponentiation |
|||
say 4 ** 7; # Exponentiation |
|||
say abs -2; # Absolute value |
say abs -2; # Absolute value |
||
say |
say (-2).abs; # Absolute value |
||
say floor -3.5; # Floor |
|||
say (-3.5).floor; # Floor |
|||
say ceiling pi; # Ceiling |
say ceiling pi; # Ceiling |
||
say |
say pi.ceiling; # Ceiling |
||
say e ** π\i + 1 ≅ 0; # :-)</lang> |
|||
=={{header|PHP}}== |
=={{header|PHP}}== |