Real constants and functions: Difference between revisions

Content added Content deleted
m (→‎{{header|Icon}} and {{header|Unicon}}: Regularize non-standard header markup)
No edit summary
Line 580: Line 580:
(expt x y) ; power
(expt x y) ; power
</lang>
</lang>

=={{header|Crystal}}==
<lang ruby>x = 3.25
y = 4

puts x.abs # absolute value
puts x.floor # floor
puts x.ceil # ceiling
puts x ** y # power
puts

include Math # without including

puts E # puts Math::E -- exponential constant
puts PI # puts Math::PI -- Archimedes circle constant
puts TAU # puts Math::TAU -- the correct circle constant, >= version 0.36
puts sqrt(x) # puts Math.sqrt(x) -- real square root
puts log(x) # puts Math.log(x) -- natural logarithm
puts log10(x) # puts Math.log10(x) -- base 10 logarithm
puts log(x, y) # puts Math.log(x, y) -- logarithm x base y
puts exp(x) # puts Math.exp(x) -- exponential
puts E**x # put Math::E**x -- same
</lang>

{{0ut}}<pre>
3.25
3.0
4.0
111.56640625

2.718281828459045
3.141592653589793
6.283185307179586
1.8027756377319946
1.1786549963416462
0.5118833609788744
0.8502198590705461
25.790339917193062
25.79033991719306
</pre>


=={{header|D}}==
=={{header|D}}==