- Julia 1.0 Programming Complete Reference Guide
- Ivo Balbaert Adrian Salceanu
- 192字
- 2021-06-24 14:21:42
Rational and complex numbers
Julia supports these types out of the box. The global constant im represents the square root of -1, so that 3.2 + 7.1im is a complex number with floating point coefficients, so it is of the type Complex{Float64}.
This is the first example of a parametric type in Julia. For this example, we can write this as Complex{T}, where type T can take a number of different type values, such as Int32, Int64, or Float64.
All operations and elementary functions, such as exp(), sqrt(), sinh(), real(), imag(), abs(), and so on, are also defined on complex numbers; for example, abs(3.2 + 7.1im) = 7.787810988975015.
If a and b are two variables that contain a number, use complex(a,b) to form a complex number with them. Rational numbers are useful when you want to work with exact ratios of integers, for example, 3//4, which is of type Rational{Int64}.
Again, comparisons and standard operations are defined: float() converts to a floating point number, and num() and den() gives the numerator and denominator. Both types work together seamlessly with all the other numeric types.
- Software Defined Networking with OpenFlow
- PostgreSQL for Data Architects
- R的極客理想:工具篇
- Getting Started with Hazelcast(Second Edition)
- ASP.NET開發(fā)與應(yīng)用教程
- Visual Basic程序設(shè)計(jì)上機(jī)實(shí)驗(yàn)教程
- HTML5秘籍(第2版)
- HTML+CSS+JavaScript網(wǎng)頁制作:從入門到精通(第4版)
- Mastering SciPy
- Visual Basic 開發(fā)從入門到精通
- Slick2D Game Development
- Java無難事:詳解Java編程核心思想與技術(shù)
- PostGIS Cookbook
- Java從入門到精通(微視頻精編版)
- Lucene 4 Cookbook