The Zig Programming Language 0.5.0 DocumentationNumber to Unsigned Integer Cast Truncates Data Integer Overflow Default Operations Standard Library Math Functions Builtin Overflow Functions Wrapping Operations Exact Left Shift Overflow Exact Right Shift standard library: const std = @import("std"); const inf = std.math.inf(f32); const negative_inf = -std.math.inf(f64); const nan = std.math.nan(f128); Floating Point Operations By default floating point wrapping behavior. Invokes Peer Type Resolution for the operands. See also @addWithOverflow. u32(std.math.maxInt(u a - b a -= b Integers Floats Subtraction. Can cause overflow for integers. Invokes Peer0 码力 | 224 页 | 5.80 MB | 1 年前3
The Zig Programming Language 0.12.0 Documentationfloat_special_values.zig const std = @import("std"); const inf = std.math.inf(f32); const negative_inf = -std.math.inf(f64); const nan = std.math.nan(f128); Floating Point Operations By default floating point ( >> , << , & , | , ~ , etc.) Comparison operators ( < , > , == , etc.) It is prohibited to use a math operator on a mixture of scalars (individual numbers) and vectors. Zig provides the @splat builtin const a = @Vector(4, i32){ 1, 2, 3, 4 }; const b = @Vector(4, i32){ 5, 6, 7, 8 }; // Math operations take place element-wise. const c = a + b; // Individual vector elements can be0 码力 | 241 页 | 7.37 MB | 1 年前3
The Zig Programming Language 0.4.0 DocumentationNumber to Unsigned Integer Cast Truncates Data Integer Overflow Default Operations Standard Library Math Functions Builtin Overflow Functions Wrapping Operations Exact Left Shift Overflow Exact Right Shift standard library: const std = @import("std"); const inf = std.math.inf(f32); const negative_inf = -std.math.inf(f64); const nan = std.math.nan(f128); Floating Point Operations By default floating point wrapping behavior. Invokes Peer Type Resolution for the operands. See also @addWithOverflow. u32(std.math.maxInt(u a - b a -= b Integers Floats Subtraction. Can cause overflow for integers. Invokes Peer0 码力 | 207 页 | 5.29 MB | 1 年前3
The Zig Programming Language 0.11.0 Documentationfloat_special_values.zig 1 const std = @import("std"); 2 3 const inf = std.math.inf(f32); 4 const negative_inf = -std.math.inf(f64); 5 const nan = std.math.nan(f128); 9.2. Floating Point Operations By default floating also @addWithOverflow. 1 @as(u32, std.math.maxI a +| b a +|= b Integers Saturating Addition. Invokes Peer Type Resolution for the operands. 1 @as(u32, std.math.maxI a - b a -= b Integers Floats Subtraction Integers Wrapping Negation. Guaranteed to have twos-complement wrapping behavior. 1 -%@as(i32, std.math.mi a * b a *= b Integers Floats Multiplication. Can cause overflow for integers. Invokes Peer0 码力 | 238 页 | 7.80 MB | 1 年前3
The Zig Programming Language 0.6.0 Documentationstandard library: const std = @import("std"); const inf = std.math.inf(f32); const negative_inf = -std.math.inf(f64); const nan = std.math.nan(f128); Floating Point Operations By default floating point particular location: test "basic math" { const x = 1; const y = 2; if (x + y != 3) { unreachable; } } $ zig test test.zig 1/1 test "basic math"...OK All 1 tests passed. In fact to parse a string into a 64-bit integer: test.zig const std = @import("std"); const maxInt = std.math.maxInt; pub fn parseU64(buf: []const u8, radix: u8) !u64 { var x: u64 = 0; for (buf) |c|0 码力 | 214 页 | 5.37 MB | 1 年前3
The Zig Programming Language 0.7.1 Documentationstandard library: const std = @import("std"); const inf = std.math.inf(f32); const negative_inf = -std.math.inf(f64); const nan = std.math.nan(f128); Floating Point Operations By default floating point particular location: test "basic math" { const x = 1; const y = 2; if (x + y != 3) { unreachable; } } $ zig test test.zig 1/1 test "basic math"... OK All 1 tests passed. In fact to parse a string into a 64-bit integer: test.zig const std = @import("std"); const maxInt = std.math.maxInt; pub fn parseU64(buf: []const u8, radix: u8) !u64 { var x: u64 = 0; for (buf) |c|0 码力 | 225 页 | 5.74 MB | 1 年前3
The Zig Programming Language 0.9.1 Documentationfloat_special_values.zig 1 const std = @import("std"); 2 3 const inf = std.math.inf(f32); 4 const negative_inf = -std.math.inf(f64); 5 const nan = std.math.nan(f128); Floating Point Operations By default floating also @addWithOverflow. 1 @as(u32, std.math.maxI a +| b a +|= b Integers Saturating Addition. Invokes Peer Type Resolution for the operands. 1 @as(u32, std.math.maxI Syntax Relevant Types Description Integers Wrapping Negation. Guaranteed to have twos-complement wrapping behavior. 1 -%@as(i32, std.math.mi a * b a *= b Integers Floats Multiplication. Can cause overflow for integers. Invokes Peer0 码力 | 234 页 | 7.90 MB | 1 年前3
The Zig Programming Language 0.8.1 Documentationstandard library: const std = @import("std"); const inf = std.math.inf(f32); const negative_inf = -std.math.inf(f64); const nan = std.math.nan(f128); Floating Point Operations By default floating point particular location: test "basic math" { const x = 1; const y = 2; if (x + y != 3) { unreachable; } } $ zig test test.zig Test [1/1] test "basic math"... All 1 tests passed. In to parse a string into a 64-bit integer: test.zig const std = @import("std"); const maxInt = std.math.maxInt; pub fn parseU64(buf: []const u8, radix: u8) !u64 { var x: u64 = 0; for (buf) |c|0 码力 | 234 页 | 6.01 MB | 1 年前3
The Zig Programming Language 0.1.1 Documentationunreachable is used to assert that control flow will never happen upon a // particular location: test "basic math" { const x = 1; const y = 2; if (x + y != 3) { unreachable; } } // in fact hit unreachable. test "this will fail" { assert(false); } $ zig test test.zig Test 1/2 basic math...OK Test 2/2 this will fail...reached unreachable code test.zig:13:14: 0x00000000002033ac in ??? numerator. @divExact(6, 3) == 2 @divExact(a, b) * b == a See also: @divTrunc @divFloor @import("std").math.divExact @divFloor @divFloor(numerator: T, denominator: T) -> T Floored division. Rounds toward0 码力 | 82 页 | 2.67 MB | 1 年前3
The Zig Programming Language 0.10.1 Documentationfloat_special_values.zig 1 const std = @import("std"); 2 3 const inf = std.math.inf(f32); 4 const negative_inf = -std.math.inf(f64); 5 const nan = std.math.nan(f128); Floating Point Operations By default floating also @addWithOverflow. 1 @as(u32, std.math.maxI a +| b a +|= b Integers Saturating Addition. Invokes Peer Type Resolution for the operands. 1 @as(u32, std.math.maxI Syntax Relevant Types Description Integers Wrapping Negation. Guaranteed to have twos-complement wrapping behavior. 1 -%@as(i32, std.math.mi a * b a *= b Integers Floats Multiplication. Can cause overflow for integers. Invokes Peer0 码力 | 239 页 | 8.03 MB | 1 年前3
共 45 条
- 1
- 2
- 3
- 4
- 5













