Arithmetic/Complex: Difference between revisions

→‎{{header|Ruby}}: Added demo of CMath lib
(→‎{{header|Ruby}}: Added demo of CMath lib)
Line 3,703:
puts 1.0 / a # works, but forces floating-point math
puts 1 / a # might truncate to integer</lang>
 
CMath is a standard library that provides trigonometric and transcendental functions for complex numbers:
 
<lang ruby>require "cmath"
CMath.sqrt(-9) #=> 0+3.0i
CMath.acos(0+3.0i) #=> (1.5707963267948966-1.8184464592320668i)
#etc</lang>
 
=={{header|Rust}}==
1,149

edits