-
expressions and assignment versus mutation
4.3 Stylistic Conventions
5 Integers and Floating-Point Numbers
5.1 Integers
5.2 Floating-Point Numbers
5.3 Arbitrary Precision Arithmetic
5.4 Numeric mutable types like arrays, whose contents can be changed:
julia> a = [1,2,3] # an array of 3 integers
3-element Vector{Int64}:
1
2
3
julia> b = a # both b and a are names for the same array!
3-element stylistic conventions, see the Style Guide.
## Chapter 5
## I ntegers and Floating-Point Numbers
Integers and floating-point values are the basic building blocks of arithmetic and computation. Built-in
0 码力 |
2007 页 |
6.73 MB
| 11 月前 3
-
declaration, makes `error.ArgNotFound` available
error ArgNotFound;
pub fn main() -> %void {
// integers
const one_plus_one: i32 = 1 + 1;
%%io.stdout.printf("1 + 1 = {}
", one_plus_one); and while (true) {}|
|type|(none)|the type of types|
|error|(none)|an error code|
See also:
• Integers
• Floats
• void
• Errors
## Primitive Values
|Name|Description|
|---|---|
|true and false|bool ple|
|---|---|---|---|
|a + b a += b|• Integers • Floats|Addition. • Can cause overflow for integers.|2 + 5 == 7|
|---|---|---|---|
|a + % b a + % = b|• Integers|Wrapping Addition. • Guaranteed to have
0 码力 |
82 页 |
2.67 MB
| 2 年前 3
-
std.debug.warn;
const os = std.os;
const assert = std.debug.assert;
pub fn main() void {
// integers
const one_plus_one: i32 = 1 + 1;
warn("1 + 1 = {}
", one_plus_one);
// floats unreachable, and while (true) {}|
|type|(none)|the type of types|
|error|(none)|an error code|
• Integers
• Floats
• void
• Errors
## Primitive Values
|Name|Description|
|---|---|
|true and false|bool Types|Description|Example|
|---|---|---|---|
|a + ba += b|• Integers• Floats|Addition.• Can cause overflow for integers.|2 + 5 == 7|
|a + % ba + % = b|• Integers|Wrapping Addition.• Guaranteed to have twos-complement
0 码力 |
117 页 |
2.84 MB
| 2 年前 3
-
@import("std");
const os = std.os;
const assert = std.debug.assert;
pub fn main() void {
// integers
const one_plus_one: i32 = 1 + 1;
print("1 + 1 = {}", {one_plus_one});
// floats values. The type of float literals.|
In addition to the integer types above, arbitrary bit-width integers can be referenced by using an identifier of i or u followed by digits. For example, the identifier a signed 7-bit integer. The maximum allowed bit-width of an integer type is 65535.
See also:
• Integers
• Floats
• void
• Errors
• @Type
#### 5.2. Primitive Values
Primitive Values
|Name|Description|
0 码力 |
238 页 |
7.80 MB
| 2 年前 3
-
@import("std");
const os = std.os;
const assert = std.debug.assert;
pub fn main() void {
// integers
const one_plus_one: i32 = 1 + 1;
print("1 + 1 = {}n", {one_plus_one});
// floats values. The type of float literals.|
In addition to the integer types above, arbitrary bit-width integers can be referenced by using an identifier of i or u followed by digits. For example, the identifier a signed 7-bit integer. The maximum allowed bit-width of an integer type is 65535.
See also:
• Integers
• Floats
• void
• Errors
• @Type
## Primitive Values
Primitive Values
|Name|Description|
0 码力 |
234 页 |
7.90 MB
| 2 年前 3
-
undefined
- Variables
- Global Variables
- Thread Local Variables
- Local Variables
- Integers
- Integer Literals
- Runtime Integer Values
- Floats
- Float Literals
- Floating @import("std");
const os = std.os;
const assert = std.debug.assert;
pub fn main() void {
// integers
const one_plus_one: i32 = 1 + 1;
warn("1 + 1 = {}
", one_plus_one);
// floats
const seven_div_three: values. The type of float literals.|
In addition to the integer types above, arbitrary bit-width integers can be referenced by using an identifier of i or u followed by digits. For example, the identifier
0 码力 |
207 页 |
5.29 MB
| 2 年前 3
-
@import("std");
const os = std.os;
const assert = std.debug.assert;
pub fn main() void {
// integers
const one_plus_one: i32 = 1 + 1;
print("1 + 1 = {}\\n", {one_plus_one});
// values. The type of float literals.|
In addition to the integer types above, arbitrary bit-width integers can be referenced by using an identifier of i or u followed by digits. For example, the identifier a signed 7-bit integer. The maximum allowed bit-width of an integer type is 65535.
See also:
• Integers
• Floats
• void
• Errors
• @Type
## Primitive Values
Primitive Values
|Name|Description|
0 码力 |
239 页 |
8.03 MB
| 2 年前 3
-
@import("std");
const os = std.os;
const assert = std.debug.assert;
pub fn main() void {
// integers
const one_plus_one: i32 = 1 + 1;
warn("1 + 1 = {}\\n", {one_plus_one});
// values. The type of float literals.|
In addition to the integer types above, arbitrary bit-width integers can be referenced by using an identifier of i or u followed by digits. For example, the identifier a signed 7-bit integer. The maximum allowed bit-width of an integer type is 65535.
See also:
• Integers
• Floats
• void
• Errors
• @Type
## Primitive Values
|Name|Description|
|---|---|
|true and
0 码力 |
214 页 |
5.37 MB
| 2 年前 3
-
undefined
- Variables
- Global Variables
- Thread Local Variables
- Local Variables
- Integers
- Integer Literals
- Runtime Integer Values
- Floats
- Float Literals
- Floating @import("std");
const os = std.os;
const assert = std.debug.assert;
pub fn main() void {
// integers
const one_plus_one: i32 = 1 + 1;
warn("1 + 1 = {}\\n", one_plus_one);
// floats values. The type of float literals.|
In addition to the integer types above, arbitrary bit-width integers can be referenced by using an identifier of i or u followed by digits. For example, the identifier
0 码力 |
224 页 |
5.80 MB
| 2 年前 3
-
@import("std");
const os = std.os;
const assert = std.debug.assert;
pub fn main() void {
//
integers
const one_plus_one: i32 = 1 + 1;
print("1 + 1 = {}\\n", {one_plus_one});
// literals.
In addition to the integer types above, arbitrary bit-width
integers can be referenced by using an identifier of i or u followed by digits. For example, the identifier a signed 7-bit integer. The maximum allowed bit-width of an integer type is 65535.
See also:
•
Integers
• Floats
• void
• Errors
• @Type
## Primitive Values
Primitive Values
0 码力 |
241 页 |
7.37 MB
| 2 年前 3