From 2b395d4ede2d8ef356c54e1c7c09da88c634be11 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 26 Oct 2018 14:59:58 -0400 Subject: [PATCH] remove @minValue,@maxValue; add std.math.minInt,maxInt closes #1466 closes #1476 --- doc/langref.html.in | 48 ++++----- src-self-hosted/codegen.zig | 7 +- src/all_types.hpp | 16 --- src/codegen.cpp | 4 - src/ir.cpp | 120 ----------------------- src/ir_print.cpp | 18 ---- std/crypto/chacha20.zig | 5 +- std/debug/index.zig | 5 +- std/dynamic_library.zig | 5 +- std/event/loop.zig | 3 +- std/heap.zig | 3 +- std/json.zig | 3 +- std/math/asinh.zig | 3 +- std/math/atanh.zig | 3 +- std/math/big/int.zig | 60 ++++++------ std/math/copysign.zig | 7 +- std/math/cosh.zig | 3 +- std/math/fabs.zig | 3 +- std/math/hypot.zig | 9 +- std/math/ilogb.zig | 34 ++++--- std/math/index.zig | 82 +++++++++++++--- std/math/isfinite.zig | 3 +- std/math/isinf.zig | 3 +- std/math/isnan.zig | 3 +- std/math/isnormal.zig | 3 +- std/math/log10.zig | 3 +- std/math/log2.zig | 3 +- std/math/modf.zig | 3 +- std/math/sinh.zig | 3 +- std/math/sqrt.zig | 3 +- std/math/tanh.zig | 3 +- std/math/trunc.zig | 5 +- std/os/child_process.zig | 9 +- std/os/darwin.zig | 3 +- std/os/file.zig | 3 +- std/os/linux/index.zig | 7 +- std/os/linux/vdso.zig | 5 +- std/os/windows/index.zig | 11 ++- std/rand/index.zig | 11 ++- std/special/builtin.zig | 10 +- std/special/compiler_rt/floattidf.zig | 4 +- std/special/compiler_rt/floattisf.zig | 4 +- std/special/compiler_rt/floattitf.zig | 4 +- std/special/compiler_rt/floatuntidf.zig | 4 +- std/special/compiler_rt/floatuntisf.zig | 4 +- std/special/compiler_rt/floatuntitf.zig | 4 +- std/zig/parser_test.zig | 3 +- test/cases/alignof.zig | 6 +- test/cases/bitcast.zig | 8 +- test/cases/cast.zig | 7 +- test/cases/math.zig | 31 +++--- test/cases/misc.zig | 53 ++-------- test/cases/struct.zig | 32 +++--- test/compile_errors.zig | 6 +- test/standalone/brace_expansion/main.zig | 3 +- 55 files changed, 310 insertions(+), 398 deletions(-) diff --git a/doc/langref.html.in b/doc/langref.html.in index 1037be96a7..0a5ff19389 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -827,7 +827,7 @@ a +%= b{#endsyntax#} -
{#syntax#}u32(@maxValue(u32)) +% 1 == 0{#endsyntax#}
+
{#syntax#}u32(std.math.maxInt(u32)) +% 1 == 0{#endsyntax#}
@@ -866,7 +866,7 @@ a -%= b{#endsyntax#} -
{#syntax#}u32(0) -% 1 == @maxValue(u32){#endsyntax#}
+
{#syntax#}u32(0) -% 1 == std.math.maxInt(u32){#endsyntax#}
@@ -901,7 +901,7 @@ a -%= b{#endsyntax#} -
{#syntax#}-%i32(@minValue(i32)) == @minValue(i32){#endsyntax#}
+
{#syntax#}-%i32(std.math.minInt(i32)) == std.math.minInt(i32){#endsyntax#}
@@ -3298,6 +3298,9 @@ const err = (error.{FileNotFound}).FileNotFound; Here is a function to parse a string into a 64-bit integer:

{#code_begin|test#} +const std = @import("std"); +const maxInt = std.math.maxInt; + pub fn parseU64(buf: []const u8, radix: u8) !u64 { var x: u64 = 0; @@ -3327,13 +3330,13 @@ fn charToDigit(c: u8) u8 { '0' ... '9' => c - '0', 'A' ... 'Z' => c - 'A' + 10, 'a' ... 'z' => c - 'a' + 10, - else => @maxValue(u8), + else => maxInt(u8), }; } test "parse u64" { const result = try parseU64("1234", 10); - @import("std").debug.assert(result == 1234); + std.debug.assert(result == 1234); } {#code_end#}

@@ -5539,7 +5542,7 @@ test "main" {

Floored division. Rounds toward negative infinity. For unsigned integers it is the same as {#syntax#}numerator / denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#} and - {#syntax#}!(@typeId(T) == builtin.TypeId.Int and T.is_signed and numerator == @minValue(T) and denominator == -1){#endsyntax#}. + {#syntax#}!(@typeId(T) == builtin.TypeId.Int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1){#endsyntax#}.