all: zig fmt and rename "@XToY" to "@YFromX"

Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
This commit is contained in:
Eric Joldasov 2023-06-15 13:14:16 +06:00 committed by Andrew Kelley
parent a6c8ee5231
commit 50339f595a
665 changed files with 6204 additions and 5889 deletions

View file

@ -376,7 +376,7 @@ set(ZIG_STAGE2_SOURCES
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfdi.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfdi.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfsi.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfsi.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfti.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfti.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/float_to_int.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/int_from_float.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdidf.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdidf.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdihf.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdihf.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdisf.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdisf.zig"
@ -417,7 +417,7 @@ set(ZIG_STAGE2_SOURCES
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/getf2.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/getf2.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/gexf2.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/gexf2.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/int.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/int.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/int_to_float.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/float_from_int.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/log.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/log.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/log10.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/log10.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/log2.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/log2.zig"

View file

@ -487,7 +487,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
.cpu_arch = .wasm32, .cpu_arch = .wasm32,
.os_tag = .wasi, .os_tag = .wasi,
}; };
target.cpu_features_add.addFeature(@enumToInt(std.Target.wasm.Feature.bulk_memory)); target.cpu_features_add.addFeature(@intFromEnum(std.Target.wasm.Feature.bulk_memory));
const exe = addCompilerStep(b, .ReleaseSmall, target); const exe = addCompilerStep(b, .ReleaseSmall, target);

View file

@ -2763,14 +2763,14 @@ test "comptime pointers" {
} }
} }
{#code_end#} {#code_end#}
<p>To convert an integer address into a pointer, use {#syntax#}@intToPtr{#endsyntax#}. <p>To convert an integer address into a pointer, use {#syntax#}@ptrFromInt{#endsyntax#}.
To convert a pointer to an integer, use {#syntax#}@ptrToInt{#endsyntax#}:</p> To convert a pointer to an integer, use {#syntax#}@intFromPtr{#endsyntax#}:</p>
{#code_begin|test|test_integer_pointer_conversion#} {#code_begin|test|test_integer_pointer_conversion#}
const expect = @import("std").testing.expect; const expect = @import("std").testing.expect;
test "@ptrToInt and @intToPtr" { test "@intFromPtr and @ptrFromInt" {
const ptr = @intToPtr(*i32, 0xdeadbee0); const ptr = @ptrFromInt(*i32, 0xdeadbee0);
const addr = @ptrToInt(ptr); const addr = @intFromPtr(ptr);
try expect(@TypeOf(addr) == usize); try expect(@TypeOf(addr) == usize);
try expect(addr == 0xdeadbee0); try expect(addr == 0xdeadbee0);
} }
@ -2780,18 +2780,18 @@ test "@ptrToInt and @intToPtr" {
{#code_begin|test|test_comptime_pointer_conversion#} {#code_begin|test|test_comptime_pointer_conversion#}
const expect = @import("std").testing.expect; const expect = @import("std").testing.expect;
test "comptime @intToPtr" { test "comptime @ptrFromInt" {
comptime { comptime {
// Zig is able to do this at compile-time, as long as // Zig is able to do this at compile-time, as long as
// ptr is never dereferenced. // ptr is never dereferenced.
const ptr = @intToPtr(*i32, 0xdeadbee0); const ptr = @ptrFromInt(*i32, 0xdeadbee0);
const addr = @ptrToInt(ptr); const addr = @intFromPtr(ptr);
try expect(@TypeOf(addr) == usize); try expect(@TypeOf(addr) == usize);
try expect(addr == 0xdeadbee0); try expect(addr == 0xdeadbee0);
} }
} }
{#code_end#} {#code_end#}
{#see_also|Optional Pointers|@intToPtr|@ptrToInt|C Pointers#} {#see_also|Optional Pointers|@ptrFromInt|@intFromPtr|C Pointers#}
{#header_open|volatile#} {#header_open|volatile#}
<p>Loads and stores are assumed to not have side effects. If a given load or store <p>Loads and stores are assumed to not have side effects. If a given load or store
should have side effects, such as Memory Mapped Input/Output (MMIO), use {#syntax#}volatile{#endsyntax#}. should have side effects, such as Memory Mapped Input/Output (MMIO), use {#syntax#}volatile{#endsyntax#}.
@ -2801,7 +2801,7 @@ test "comptime @intToPtr" {
const expect = @import("std").testing.expect; const expect = @import("std").testing.expect;
test "volatile" { test "volatile" {
const mmio_ptr = @intToPtr(*volatile u8, 0x12345678); const mmio_ptr = @ptrFromInt(*volatile u8, 0x12345678);
try expect(@TypeOf(mmio_ptr) == *volatile u8); try expect(@TypeOf(mmio_ptr) == *volatile u8);
} }
{#code_end#} {#code_end#}
@ -2942,8 +2942,8 @@ const expect = std.testing.expect;
test "allowzero" { test "allowzero" {
var zero: usize = 0; var zero: usize = 0;
var ptr = @intToPtr(*allowzero i32, zero); var ptr = @ptrFromInt(*allowzero i32, zero);
try expect(@ptrToInt(ptr) == 0); try expect(@intFromPtr(ptr) == 0);
} }
{#code_end#} {#code_end#}
{#header_close#} {#header_close#}
@ -3006,7 +3006,7 @@ test "basic slices" {
// while using the `ptr` field gives a many-item pointer. // while using the `ptr` field gives a many-item pointer.
try expect(@TypeOf(slice.ptr) == [*]i32); try expect(@TypeOf(slice.ptr) == [*]i32);
try expect(@TypeOf(&slice[0]) == *i32); try expect(@TypeOf(&slice[0]) == *i32);
try expect(@ptrToInt(slice.ptr) == @ptrToInt(&slice[0])); try expect(@intFromPtr(slice.ptr) == @intFromPtr(&slice[0]));
// Slices have array bounds checking. If you try to access something out // Slices have array bounds checking. If you try to access something out
// of bounds, you'll get a safety check failure: // of bounds, you'll get a safety check failure:
@ -3448,8 +3448,8 @@ var bit_field = BitField{
}; };
test "pointers of sub-byte-aligned fields share addresses" { test "pointers of sub-byte-aligned fields share addresses" {
try expect(@ptrToInt(&bit_field.a) == @ptrToInt(&bit_field.b)); try expect(@intFromPtr(&bit_field.a) == @intFromPtr(&bit_field.b));
try expect(@ptrToInt(&bit_field.a) == @ptrToInt(&bit_field.c)); try expect(@intFromPtr(&bit_field.a) == @intFromPtr(&bit_field.c));
} }
{#code_end#} {#code_end#}
<p> <p>
@ -3664,9 +3664,9 @@ const Value = enum(u2) {
// Now you can cast between u2 and Value. // Now you can cast between u2 and Value.
// The ordinal value starts from 0, counting up by 1 from the previous member. // The ordinal value starts from 0, counting up by 1 from the previous member.
test "enum ordinal value" { test "enum ordinal value" {
try expect(@enumToInt(Value.zero) == 0); try expect(@intFromEnum(Value.zero) == 0);
try expect(@enumToInt(Value.one) == 1); try expect(@intFromEnum(Value.one) == 1);
try expect(@enumToInt(Value.two) == 2); try expect(@intFromEnum(Value.two) == 2);
} }
// You can override the ordinal value for an enum. // You can override the ordinal value for an enum.
@ -3676,9 +3676,9 @@ const Value2 = enum(u32) {
million = 1000000, million = 1000000,
}; };
test "set enum ordinal value" { test "set enum ordinal value" {
try expect(@enumToInt(Value2.hundred) == 100); try expect(@intFromEnum(Value2.hundred) == 100);
try expect(@enumToInt(Value2.thousand) == 1000); try expect(@intFromEnum(Value2.thousand) == 1000);
try expect(@enumToInt(Value2.million) == 1000000); try expect(@intFromEnum(Value2.million) == 1000000);
} }
// You can also override only some values. // You can also override only some values.
@ -3690,11 +3690,11 @@ const Value3 = enum(u4) {
e, e,
}; };
test "enum implicit ordinal values and overridden values" { test "enum implicit ordinal values and overridden values" {
try expect(@enumToInt(Value3.a) == 0); try expect(@intFromEnum(Value3.a) == 0);
try expect(@enumToInt(Value3.b) == 8); try expect(@intFromEnum(Value3.b) == 8);
try expect(@enumToInt(Value3.c) == 9); try expect(@intFromEnum(Value3.c) == 9);
try expect(@enumToInt(Value3.d) == 4); try expect(@intFromEnum(Value3.d) == 4);
try expect(@enumToInt(Value3.e) == 5); try expect(@intFromEnum(Value3.e) == 5);
} }
// Enums can have methods, the same as structs and unions. // Enums can have methods, the same as structs and unions.
@ -3811,7 +3811,7 @@ test "switch using enum literals" {
It must specify a tag type and cannot consume every enumeration value. It must specify a tag type and cannot consume every enumeration value.
</p> </p>
<p> <p>
{#link|@intToEnum#} on a non-exhaustive enum involves the safety semantics {#link|@enumFromInt#} on a non-exhaustive enum involves the safety semantics
of {#link|@intCast#} to the integer tag type, but beyond that always results in of {#link|@intCast#} to the integer tag type, but beyond that always results in
a well-defined enum value. a well-defined enum value.
</p> </p>
@ -4385,7 +4385,7 @@ fn withFor(any: AnySlice) usize {
// With `inline for` the function gets generated as // With `inline for` the function gets generated as
// a series of `if` statements relying on the optimizer // a series of `if` statements relying on the optimizer
// to convert it to a switch. // to convert it to a switch.
if (field.value == @enumToInt(any)) { if (field.value == @intFromEnum(any)) {
return @field(any, field.name).len; return @field(any, field.name).len;
} }
} }
@ -4428,7 +4428,7 @@ fn getNum(u: U) u32 {
// `u.a` or `u.b` and `tag` is `u`'s comptime-known tag value. // `u.a` or `u.b` and `tag` is `u`'s comptime-known tag value.
inline else => |num, tag| { inline else => |num, tag| {
if (tag == .b) { if (tag == .b) {
return @floatToInt(u32, num); return @intFromFloat(u32, num);
} }
return num; return num;
} }
@ -6625,19 +6625,19 @@ test "coercion from homogenous tuple to array" {
<ul> <ul>
<li>{#link|@bitCast#} - change type but maintain bit representation</li> <li>{#link|@bitCast#} - change type but maintain bit representation</li>
<li>{#link|@alignCast#} - make a pointer have more alignment</li> <li>{#link|@alignCast#} - make a pointer have more alignment</li>
<li>{#link|@boolToInt#} - convert true to 1 and false to 0</li> <li>{#link|@intFromBool#} - convert true to 1 and false to 0</li>
<li>{#link|@enumToInt#} - obtain the integer tag value of an enum or tagged union</li> <li>{#link|@intFromEnum#} - obtain the integer tag value of an enum or tagged union</li>
<li>{#link|@errSetCast#} - convert to a smaller error set</li> <li>{#link|@errSetCast#} - convert to a smaller error set</li>
<li>{#link|@errorToInt#} - obtain the integer value of an error code</li> <li>{#link|@intFromError#} - obtain the integer value of an error code</li>
<li>{#link|@floatCast#} - convert a larger float to a smaller float</li> <li>{#link|@floatCast#} - convert a larger float to a smaller float</li>
<li>{#link|@floatToInt#} - obtain the integer part of a float value</li> <li>{#link|@intFromFloat#} - obtain the integer part of a float value</li>
<li>{#link|@intCast#} - convert between integer types</li> <li>{#link|@intCast#} - convert between integer types</li>
<li>{#link|@intToEnum#} - obtain an enum value based on its integer tag value</li> <li>{#link|@enumFromInt#} - obtain an enum value based on its integer tag value</li>
<li>{#link|@intToError#} - obtain an error code based on its integer value</li> <li>{#link|@errorFromInt#} - obtain an error code based on its integer value</li>
<li>{#link|@intToFloat#} - convert an integer to a float value</li> <li>{#link|@floatFromInt#} - convert an integer to a float value</li>
<li>{#link|@intToPtr#} - convert an address to a pointer</li> <li>{#link|@ptrFromInt#} - convert an address to a pointer</li>
<li>{#link|@ptrCast#} - convert between pointer types</li> <li>{#link|@ptrCast#} - convert between pointer types</li>
<li>{#link|@ptrToInt#} - obtain the address of a pointer</li> <li>{#link|@intFromPtr#} - obtain the address of a pointer</li>
<li>{#link|@truncate#} - convert between integer types, chopping off bits</li> <li>{#link|@truncate#} - convert between integer types, chopping off bits</li>
</ul> </ul>
{#header_close#} {#header_close#}
@ -6744,8 +6744,8 @@ fn peerTypeEmptyArrayAndSliceAndError(a: bool, slice: []u8) anyerror![]u8 {
} }
test "peer type resolution: *const T and ?*T" { test "peer type resolution: *const T and ?*T" {
const a = @intToPtr(*const usize, 0x123456780); const a = @ptrFromInt(*const usize, 0x123456780);
const b = @intToPtr(?*usize, 0x123456780); const b = @ptrFromInt(?*usize, 0x123456780);
try expect(a == b); try expect(a == b);
try expect(b == a); try expect(b == a);
} }
@ -7542,7 +7542,7 @@ pub fn main() void {
{#target_linux_x86_64#} {#target_linux_x86_64#}
pub fn main() noreturn { pub fn main() noreturn {
const msg = "hello world\n"; const msg = "hello world\n";
_ = syscall3(SYS_write, STDOUT_FILENO, @ptrToInt(msg), msg.len); _ = syscall3(SYS_write, STDOUT_FILENO, @intFromPtr(msg), msg.len);
_ = syscall1(SYS_exit, 0); _ = syscall1(SYS_exit, 0);
unreachable; unreachable;
} }
@ -7857,7 +7857,7 @@ comptime {
Asserts that {#syntax#}@sizeOf(@TypeOf(value)) == @sizeOf(DestType){#endsyntax#}. Asserts that {#syntax#}@sizeOf(@TypeOf(value)) == @sizeOf(DestType){#endsyntax#}.
</p> </p>
<p> <p>
Asserts that {#syntax#}@typeInfo(DestType) != .Pointer{#endsyntax#}. Use {#syntax#}@ptrCast{#endsyntax#} or {#syntax#}@intToPtr{#endsyntax#} if you need this. Asserts that {#syntax#}@typeInfo(DestType) != .Pointer{#endsyntax#}. Use {#syntax#}@ptrCast{#endsyntax#} or {#syntax#}@ptrFromInt{#endsyntax#} if you need this.
</p> </p>
<p> <p>
Can be used for these things for example: Can be used for these things for example:
@ -7884,8 +7884,8 @@ comptime {
{#see_also|@offsetOf#} {#see_also|@offsetOf#}
{#header_close#} {#header_close#}
{#header_open|@boolToInt#} {#header_open|@intFromBool#}
<pre>{#syntax#}@boolToInt(value: bool) u1{#endsyntax#}</pre> <pre>{#syntax#}@intFromBool(value: bool) u1{#endsyntax#}</pre>
<p> <p>
Converts {#syntax#}true{#endsyntax#} to {#syntax#}@as(u1, 1){#endsyntax#} and {#syntax#}false{#endsyntax#} to Converts {#syntax#}true{#endsyntax#} to {#syntax#}@as(u1, 1){#endsyntax#} and {#syntax#}false{#endsyntax#} to
{#syntax#}@as(u1, 0){#endsyntax#}. {#syntax#}@as(u1, 0){#endsyntax#}.
@ -8348,8 +8348,8 @@ test "main" {
{#see_also|@import#} {#see_also|@import#}
{#header_close#} {#header_close#}
{#header_open|@enumToInt#} {#header_open|@intFromEnum#}
<pre>{#syntax#}@enumToInt(enum_or_tagged_union: anytype) anytype{#endsyntax#}</pre> <pre>{#syntax#}@intFromEnum(enum_or_tagged_union: anytype) anytype{#endsyntax#}</pre>
<p> <p>
Converts an enumeration value into its integer tag type. When a tagged union is passed, Converts an enumeration value into its integer tag type. When a tagged union is passed,
the tag value is used as the enumeration value. the tag value is used as the enumeration value.
@ -8358,7 +8358,7 @@ test "main" {
If there is only one possible enum value, the result is a {#syntax#}comptime_int{#endsyntax#} If there is only one possible enum value, the result is a {#syntax#}comptime_int{#endsyntax#}
known at {#link|comptime#}. known at {#link|comptime#}.
</p> </p>
{#see_also|@intToEnum#} {#see_also|@enumFromInt#}
{#header_close#} {#header_close#}
{#header_open|@errorName#} {#header_open|@errorName#}
@ -8383,8 +8383,8 @@ test "main" {
</p> </p>
{#header_close#} {#header_close#}
{#header_open|@errorToInt#} {#header_open|@intFromError#}
<pre>{#syntax#}@errorToInt(err: anytype) std.meta.Int(.unsigned, @sizeOf(anyerror) * 8){#endsyntax#}</pre> <pre>{#syntax#}@intFromError(err: anytype) std.meta.Int(.unsigned, @sizeOf(anyerror) * 8){#endsyntax#}</pre>
<p> <p>
Supports the following types: Supports the following types:
</p> </p>
@ -8400,7 +8400,7 @@ test "main" {
It is generally recommended to avoid this It is generally recommended to avoid this
cast, as the integer representation of an error is not stable across source code changes. cast, as the integer representation of an error is not stable across source code changes.
</p> </p>
{#see_also|@intToError#} {#see_also|@errorFromInt#}
{#header_close#} {#header_close#}
{#header_open|@errSetCast#} {#header_open|@errSetCast#}
@ -8526,8 +8526,8 @@ test "decl access by string" {
</p> </p>
{#header_close#} {#header_close#}
{#header_open|@floatToInt#} {#header_open|@intFromFloat#}
<pre>{#syntax#}@floatToInt(comptime DestType: type, float: anytype) DestType{#endsyntax#}</pre> <pre>{#syntax#}@intFromFloat(comptime DestType: type, float: anytype) DestType{#endsyntax#}</pre>
<p> <p>
Converts the integer part of a floating point number to the destination type. Converts the integer part of a floating point number to the destination type.
</p> </p>
@ -8535,7 +8535,7 @@ test "decl access by string" {
If the integer part of the floating point number cannot fit in the destination type, If the integer part of the floating point number cannot fit in the destination type,
it invokes safety-checked {#link|Undefined Behavior#}. it invokes safety-checked {#link|Undefined Behavior#}.
</p> </p>
{#see_also|@intToFloat#} {#see_also|@floatFromInt#}
{#header_close#} {#header_close#}
{#header_open|@frameAddress#} {#header_open|@frameAddress#}
@ -8666,8 +8666,8 @@ test "integer cast panic" {
</p> </p>
{#header_close#} {#header_close#}
{#header_open|@intToEnum#} {#header_open|@enumFromInt#}
<pre>{#syntax#}@intToEnum(comptime DestType: type, integer: anytype) DestType{#endsyntax#}</pre> <pre>{#syntax#}@enumFromInt(comptime DestType: type, integer: anytype) DestType{#endsyntax#}</pre>
<p> <p>
Converts an integer into an {#link|enum#} value. Converts an integer into an {#link|enum#} value.
</p> </p>
@ -8675,11 +8675,11 @@ test "integer cast panic" {
Attempting to convert an integer which represents no value in the chosen enum type invokes Attempting to convert an integer which represents no value in the chosen enum type invokes
safety-checked {#link|Undefined Behavior#}. safety-checked {#link|Undefined Behavior#}.
</p> </p>
{#see_also|@enumToInt#} {#see_also|@intFromEnum#}
{#header_close#} {#header_close#}
{#header_open|@intToError#} {#header_open|@errorFromInt#}
<pre>{#syntax#}@intToError(value: std.meta.Int(.unsigned, @sizeOf(anyerror) * 8)) anyerror{#endsyntax#}</pre> <pre>{#syntax#}@errorFromInt(value: std.meta.Int(.unsigned, @sizeOf(anyerror) * 8)) anyerror{#endsyntax#}</pre>
<p> <p>
Converts from the integer representation of an error into {#link|The Global Error Set#} type. Converts from the integer representation of an error into {#link|The Global Error Set#} type.
</p> </p>
@ -8691,20 +8691,20 @@ test "integer cast panic" {
Attempting to convert an integer that does not correspond to any error results in Attempting to convert an integer that does not correspond to any error results in
safety-protected {#link|Undefined Behavior#}. safety-protected {#link|Undefined Behavior#}.
</p> </p>
{#see_also|@errorToInt#} {#see_also|@intFromError#}
{#header_close#} {#header_close#}
{#header_open|@intToFloat#} {#header_open|@floatFromInt#}
<pre>{#syntax#}@intToFloat(comptime DestType: type, int: anytype) DestType{#endsyntax#}</pre> <pre>{#syntax#}@floatFromInt(comptime DestType: type, int: anytype) DestType{#endsyntax#}</pre>
<p> <p>
Converts an integer to the closest floating point representation. To convert the other way, use {#link|@floatToInt#}. This cast is always safe. Converts an integer to the closest floating point representation. To convert the other way, use {#link|@intFromFloat#}. This cast is always safe.
</p> </p>
{#header_close#} {#header_close#}
{#header_open|@intToPtr#} {#header_open|@ptrFromInt#}
<pre>{#syntax#}@intToPtr(comptime DestType: type, address: usize) DestType{#endsyntax#}</pre> <pre>{#syntax#}@ptrFromInt(comptime DestType: type, address: usize) DestType{#endsyntax#}</pre>
<p> <p>
Converts an integer to a {#link|pointer|Pointers#}. To convert the other way, use {#link|@ptrToInt#}. Casting an address of 0 to a destination type Converts an integer to a {#link|pointer|Pointers#}. To convert the other way, use {#link|@intFromPtr#}. Casting an address of 0 to a destination type
which in not {#link|optional|Optional Pointers#} and does not have the {#syntax#}allowzero{#endsyntax#} attribute will result in a which in not {#link|optional|Optional Pointers#} and does not have the {#syntax#}allowzero{#endsyntax#} attribute will result in a
{#link|Pointer Cast Invalid Null#} panic when runtime safety checks are enabled. {#link|Pointer Cast Invalid Null#} panic when runtime safety checks are enabled.
</p> </p>
@ -8928,13 +8928,13 @@ pub const PrefetchOptions = struct {
</ul> </ul>
{#header_close#} {#header_close#}
{#header_open|@ptrToInt#} {#header_open|@intFromPtr#}
<pre>{#syntax#}@ptrToInt(value: anytype) usize{#endsyntax#}</pre> <pre>{#syntax#}@intFromPtr(value: anytype) usize{#endsyntax#}</pre>
<p> <p>
Converts {#syntax#}value{#endsyntax#} to a {#syntax#}usize{#endsyntax#} which is the address of the pointer. Converts {#syntax#}value{#endsyntax#} to a {#syntax#}usize{#endsyntax#} which is the address of the pointer.
{#syntax#}value{#endsyntax#} can be {#syntax#}*T{#endsyntax#} or {#syntax#}?*T{#endsyntax#}. {#syntax#}value{#endsyntax#} can be {#syntax#}*T{#endsyntax#} or {#syntax#}?*T{#endsyntax#}.
</p> </p>
<p>To convert the other way, use {#link|@intToPtr#}</p> <p>To convert the other way, use {#link|@ptrFromInt#}</p>
{#header_close#} {#header_close#}
@ -10165,8 +10165,8 @@ fn getNumberOrFail() !i32 {
{#code_begin|test_err|test_comptime_invalid_error_code|integer value '11' represents no error#} {#code_begin|test_err|test_comptime_invalid_error_code|integer value '11' represents no error#}
comptime { comptime {
const err = error.AnError; const err = error.AnError;
const number = @errorToInt(err) + 10; const number = @intFromError(err) + 10;
const invalid_err = @intToError(number); const invalid_err = @errorFromInt(number);
_ = invalid_err; _ = invalid_err;
} }
{#code_end#} {#code_end#}
@ -10176,8 +10176,8 @@ const std = @import("std");
pub fn main() void { pub fn main() void {
var err = error.AnError; var err = error.AnError;
var number = @errorToInt(err) + 500; var number = @intFromError(err) + 500;
var invalid_err = @intToError(number); var invalid_err = @errorFromInt(number);
std.debug.print("value: {}\n", .{invalid_err}); std.debug.print("value: {}\n", .{invalid_err});
} }
{#code_end#} {#code_end#}
@ -10192,7 +10192,7 @@ const Foo = enum {
}; };
comptime { comptime {
const a: u2 = 3; const a: u2 = 3;
const b = @intToEnum(Foo, a); const b = @enumFromInt(Foo, a);
_ = b; _ = b;
} }
{#code_end#} {#code_end#}
@ -10208,7 +10208,7 @@ const Foo = enum {
pub fn main() void { pub fn main() void {
var a: u2 = 3; var a: u2 = 3;
var b = @intToEnum(Foo, a); var b = @enumFromInt(Foo, a);
std.debug.print("value: {s}\n", .{@tagName(b)}); std.debug.print("value: {s}\n", .{@tagName(b)});
} }
{#code_end#} {#code_end#}
@ -10255,7 +10255,7 @@ fn foo(set1: Set1) void {
<p>At compile-time:</p> <p>At compile-time:</p>
{#code_begin|test_err|test_comptime_incorrect_pointer_alignment|pointer address 0x1 is not aligned to 4 bytes#} {#code_begin|test_err|test_comptime_incorrect_pointer_alignment|pointer address 0x1 is not aligned to 4 bytes#}
comptime { comptime {
const ptr = @intToPtr(*align(1) i32, 0x1); const ptr = @ptrFromInt(*align(1) i32, 0x1);
const aligned = @alignCast(4, ptr); const aligned = @alignCast(4, ptr);
_ = aligned; _ = aligned;
} }

View file

@ -55,7 +55,7 @@ comptime {
_ = @import("compiler_rt/trunctfdf2.zig"); _ = @import("compiler_rt/trunctfdf2.zig");
_ = @import("compiler_rt/trunctfxf2.zig"); _ = @import("compiler_rt/trunctfxf2.zig");
_ = @import("compiler_rt/float_to_int.zig"); _ = @import("compiler_rt/int_from_float.zig");
_ = @import("compiler_rt/fixhfsi.zig"); _ = @import("compiler_rt/fixhfsi.zig");
_ = @import("compiler_rt/fixhfdi.zig"); _ = @import("compiler_rt/fixhfdi.zig");
_ = @import("compiler_rt/fixhfti.zig"); _ = @import("compiler_rt/fixhfti.zig");
@ -87,7 +87,7 @@ comptime {
_ = @import("compiler_rt/fixunsxfdi.zig"); _ = @import("compiler_rt/fixunsxfdi.zig");
_ = @import("compiler_rt/fixunsxfti.zig"); _ = @import("compiler_rt/fixunsxfti.zig");
_ = @import("compiler_rt/int_to_float.zig"); _ = @import("compiler_rt/float_from_int.zig");
_ = @import("compiler_rt/floatsihf.zig"); _ = @import("compiler_rt/floatsihf.zig");
_ = @import("compiler_rt/floatsisf.zig"); _ = @import("compiler_rt/floatsisf.zig");
_ = @import("compiler_rt/floatsidf.zig"); _ = @import("compiler_rt/floatsidf.zig");

View file

@ -8,7 +8,7 @@ const always_has_lse = std.Target.aarch64.featureSetHas(builtin.cpu.features, .l
/// It is intentionally not exported in order to make the machine code that /// It is intentionally not exported in order to make the machine code that
/// uses it a statically predicted direct branch rather than using the PLT, /// uses it a statically predicted direct branch rather than using the PLT,
/// which ARM is concerned would have too much overhead. /// which ARM is concerned would have too much overhead.
var __aarch64_have_lse_atomics: u8 = @boolToInt(always_has_lse); var __aarch64_have_lse_atomics: u8 = @intFromBool(always_has_lse);
fn __aarch64_cas1_relax() align(16) callconv(.Naked) void { fn __aarch64_cas1_relax() align(16) callconv(.Naked) void {
@setRuntimeSafety(false); @setRuntimeSafety(false);

View file

@ -119,21 +119,21 @@ var spinlocks: SpinlockTable = SpinlockTable{};
fn __atomic_load(size: u32, src: [*]u8, dest: [*]u8, model: i32) callconv(.C) void { fn __atomic_load(size: u32, src: [*]u8, dest: [*]u8, model: i32) callconv(.C) void {
_ = model; _ = model;
var sl = spinlocks.get(@ptrToInt(src)); var sl = spinlocks.get(@intFromPtr(src));
defer sl.release(); defer sl.release();
@memcpy(dest[0..size], src); @memcpy(dest[0..size], src);
} }
fn __atomic_store(size: u32, dest: [*]u8, src: [*]u8, model: i32) callconv(.C) void { fn __atomic_store(size: u32, dest: [*]u8, src: [*]u8, model: i32) callconv(.C) void {
_ = model; _ = model;
var sl = spinlocks.get(@ptrToInt(dest)); var sl = spinlocks.get(@intFromPtr(dest));
defer sl.release(); defer sl.release();
@memcpy(dest[0..size], src); @memcpy(dest[0..size], src);
} }
fn __atomic_exchange(size: u32, ptr: [*]u8, val: [*]u8, old: [*]u8, model: i32) callconv(.C) void { fn __atomic_exchange(size: u32, ptr: [*]u8, val: [*]u8, old: [*]u8, model: i32) callconv(.C) void {
_ = model; _ = model;
var sl = spinlocks.get(@ptrToInt(ptr)); var sl = spinlocks.get(@intFromPtr(ptr));
defer sl.release(); defer sl.release();
@memcpy(old[0..size], ptr); @memcpy(old[0..size], ptr);
@memcpy(ptr[0..size], val); @memcpy(ptr[0..size], val);
@ -149,7 +149,7 @@ fn __atomic_compare_exchange(
) callconv(.C) i32 { ) callconv(.C) i32 {
_ = success; _ = success;
_ = failure; _ = failure;
var sl = spinlocks.get(@ptrToInt(ptr)); var sl = spinlocks.get(@intFromPtr(ptr));
defer sl.release(); defer sl.release();
for (ptr[0..size], 0..) |b, i| { for (ptr[0..size], 0..) |b, i| {
if (expected[i] != b) break; if (expected[i] != b) break;
@ -168,7 +168,7 @@ fn __atomic_compare_exchange(
inline fn atomic_load_N(comptime T: type, src: *T, model: i32) T { inline fn atomic_load_N(comptime T: type, src: *T, model: i32) T {
_ = model; _ = model;
if (@sizeOf(T) > largest_atomic_size) { if (@sizeOf(T) > largest_atomic_size) {
var sl = spinlocks.get(@ptrToInt(src)); var sl = spinlocks.get(@intFromPtr(src));
defer sl.release(); defer sl.release();
return src.*; return src.*;
} else { } else {
@ -199,7 +199,7 @@ fn __atomic_load_16(src: *u128, model: i32) callconv(.C) u128 {
inline fn atomic_store_N(comptime T: type, dst: *T, value: T, model: i32) void { inline fn atomic_store_N(comptime T: type, dst: *T, value: T, model: i32) void {
_ = model; _ = model;
if (@sizeOf(T) > largest_atomic_size) { if (@sizeOf(T) > largest_atomic_size) {
var sl = spinlocks.get(@ptrToInt(dst)); var sl = spinlocks.get(@intFromPtr(dst));
defer sl.release(); defer sl.release();
dst.* = value; dst.* = value;
} else { } else {
@ -230,9 +230,9 @@ fn __atomic_store_16(dst: *u128, value: u128, model: i32) callconv(.C) void {
fn wideUpdate(comptime T: type, ptr: *T, val: T, update: anytype) T { fn wideUpdate(comptime T: type, ptr: *T, val: T, update: anytype) T {
const WideAtomic = std.meta.Int(.unsigned, smallest_atomic_fetch_exch_size * 8); const WideAtomic = std.meta.Int(.unsigned, smallest_atomic_fetch_exch_size * 8);
const addr = @ptrToInt(ptr); const addr = @intFromPtr(ptr);
const wide_addr = addr & ~(@as(T, smallest_atomic_fetch_exch_size) - 1); const wide_addr = addr & ~(@as(T, smallest_atomic_fetch_exch_size) - 1);
const wide_ptr = @alignCast(smallest_atomic_fetch_exch_size, @intToPtr(*WideAtomic, wide_addr)); const wide_ptr = @alignCast(smallest_atomic_fetch_exch_size, @ptrFromInt(*WideAtomic, wide_addr));
const inner_offset = addr & (@as(T, smallest_atomic_fetch_exch_size) - 1); const inner_offset = addr & (@as(T, smallest_atomic_fetch_exch_size) - 1);
const inner_shift = @intCast(std.math.Log2Int(T), inner_offset * 8); const inner_shift = @intCast(std.math.Log2Int(T), inner_offset * 8);
@ -255,7 +255,7 @@ fn wideUpdate(comptime T: type, ptr: *T, val: T, update: anytype) T {
inline fn atomic_exchange_N(comptime T: type, ptr: *T, val: T, model: i32) T { inline fn atomic_exchange_N(comptime T: type, ptr: *T, val: T, model: i32) T {
_ = model; _ = model;
if (@sizeOf(T) > largest_atomic_size) { if (@sizeOf(T) > largest_atomic_size) {
var sl = spinlocks.get(@ptrToInt(ptr)); var sl = spinlocks.get(@intFromPtr(ptr));
defer sl.release(); defer sl.release();
const value = ptr.*; const value = ptr.*;
ptr.* = val; ptr.* = val;
@ -305,7 +305,7 @@ inline fn atomic_compare_exchange_N(
_ = success; _ = success;
_ = failure; _ = failure;
if (@sizeOf(T) > largest_atomic_size) { if (@sizeOf(T) > largest_atomic_size) {
var sl = spinlocks.get(@ptrToInt(ptr)); var sl = spinlocks.get(@intFromPtr(ptr));
defer sl.release(); defer sl.release();
const value = ptr.*; const value = ptr.*;
if (value == expected.*) { if (value == expected.*) {
@ -362,7 +362,7 @@ inline fn fetch_op_N(comptime T: type, comptime op: std.builtin.AtomicRmwOp, ptr
}; };
if (@sizeOf(T) > largest_atomic_size) { if (@sizeOf(T) > largest_atomic_size) {
var sl = spinlocks.get(@ptrToInt(ptr)); var sl = spinlocks.get(@intFromPtr(ptr));
defer sl.release(); defer sl.release();
const value = ptr.*; const value = ptr.*;

View file

@ -63,7 +63,7 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {
.addr = start, .addr = start,
.len = end - start, .len = end - start,
}; };
const result = sysarch(ARM_SYNC_ICACHE, @ptrToInt(&arg)); const result = sysarch(ARM_SYNC_ICACHE, @intFromPtr(&arg));
std.debug.assert(result == 0); std.debug.assert(result == 0);
exportIt(); exportIt();
}, },

View file

@ -26,7 +26,7 @@ comptime {
/// Note that this matches the definition of `__ledf2`, `__eqdf2`, `__nedf2`, `__cmpdf2`, /// Note that this matches the definition of `__ledf2`, `__eqdf2`, `__nedf2`, `__cmpdf2`,
/// and `__ltdf2`. /// and `__ltdf2`.
fn __cmpdf2(a: f64, b: f64) callconv(.C) i32 { fn __cmpdf2(a: f64, b: f64) callconv(.C) i32 {
return @enumToInt(comparef.cmpf2(f64, comparef.LE, a, b)); return @intFromEnum(comparef.cmpf2(f64, comparef.LE, a, b));
} }
/// "These functions return a value less than or equal to zero if neither argument is NaN, /// "These functions return a value less than or equal to zero if neither argument is NaN,
@ -56,13 +56,13 @@ pub fn __ltdf2(a: f64, b: f64) callconv(.C) i32 {
} }
fn __aeabi_dcmpeq(a: f64, b: f64) callconv(.AAPCS) i32 { fn __aeabi_dcmpeq(a: f64, b: f64) callconv(.AAPCS) i32 {
return @boolToInt(comparef.cmpf2(f64, comparef.LE, a, b) == .Equal); return @intFromBool(comparef.cmpf2(f64, comparef.LE, a, b) == .Equal);
} }
fn __aeabi_dcmplt(a: f64, b: f64) callconv(.AAPCS) i32 { fn __aeabi_dcmplt(a: f64, b: f64) callconv(.AAPCS) i32 {
return @boolToInt(comparef.cmpf2(f64, comparef.LE, a, b) == .Less); return @intFromBool(comparef.cmpf2(f64, comparef.LE, a, b) == .Less);
} }
fn __aeabi_dcmple(a: f64, b: f64) callconv(.AAPCS) i32 { fn __aeabi_dcmple(a: f64, b: f64) callconv(.AAPCS) i32 {
return @boolToInt(comparef.cmpf2(f64, comparef.LE, a, b) != .Greater); return @intFromBool(comparef.cmpf2(f64, comparef.LE, a, b) != .Greater);
} }

View file

@ -20,7 +20,7 @@ comptime {
/// Note that this matches the definition of `__lehf2`, `__eqhf2`, `__nehf2`, `__cmphf2`, /// Note that this matches the definition of `__lehf2`, `__eqhf2`, `__nehf2`, `__cmphf2`,
/// and `__lthf2`. /// and `__lthf2`.
fn __cmphf2(a: f16, b: f16) callconv(.C) i32 { fn __cmphf2(a: f16, b: f16) callconv(.C) i32 {
return @enumToInt(comparef.cmpf2(f16, comparef.LE, a, b)); return @intFromEnum(comparef.cmpf2(f16, comparef.LE, a, b));
} }
/// "These functions return a value less than or equal to zero if neither argument is NaN, /// "These functions return a value less than or equal to zero if neither argument is NaN,

View file

@ -26,7 +26,7 @@ comptime {
/// Note that this matches the definition of `__lesf2`, `__eqsf2`, `__nesf2`, `__cmpsf2`, /// Note that this matches the definition of `__lesf2`, `__eqsf2`, `__nesf2`, `__cmpsf2`,
/// and `__ltsf2`. /// and `__ltsf2`.
fn __cmpsf2(a: f32, b: f32) callconv(.C) i32 { fn __cmpsf2(a: f32, b: f32) callconv(.C) i32 {
return @enumToInt(comparef.cmpf2(f32, comparef.LE, a, b)); return @intFromEnum(comparef.cmpf2(f32, comparef.LE, a, b));
} }
/// "These functions return a value less than or equal to zero if neither argument is NaN, /// "These functions return a value less than or equal to zero if neither argument is NaN,
@ -56,13 +56,13 @@ pub fn __ltsf2(a: f32, b: f32) callconv(.C) i32 {
} }
fn __aeabi_fcmpeq(a: f32, b: f32) callconv(.AAPCS) i32 { fn __aeabi_fcmpeq(a: f32, b: f32) callconv(.AAPCS) i32 {
return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) == .Equal); return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) == .Equal);
} }
fn __aeabi_fcmplt(a: f32, b: f32) callconv(.AAPCS) i32 { fn __aeabi_fcmplt(a: f32, b: f32) callconv(.AAPCS) i32 {
return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) == .Less); return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) == .Less);
} }
fn __aeabi_fcmple(a: f32, b: f32) callconv(.AAPCS) i32 { fn __aeabi_fcmple(a: f32, b: f32) callconv(.AAPCS) i32 {
return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) != .Greater); return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) != .Greater);
} }

View file

@ -34,7 +34,7 @@ comptime {
/// Note that this matches the definition of `__letf2`, `__eqtf2`, `__netf2`, `__cmptf2`, /// Note that this matches the definition of `__letf2`, `__eqtf2`, `__netf2`, `__cmptf2`,
/// and `__lttf2`. /// and `__lttf2`.
fn __cmptf2(a: f128, b: f128) callconv(.C) i32 { fn __cmptf2(a: f128, b: f128) callconv(.C) i32 {
return @enumToInt(comparef.cmpf2(f128, comparef.LE, a, b)); return @intFromEnum(comparef.cmpf2(f128, comparef.LE, a, b));
} }
/// "These functions return a value less than or equal to zero if neither argument is NaN, /// "These functions return a value less than or equal to zero if neither argument is NaN,
@ -71,34 +71,34 @@ const SparcFCMP = enum(i32) {
}; };
fn _Qp_cmp(a: *const f128, b: *const f128) callconv(.C) i32 { fn _Qp_cmp(a: *const f128, b: *const f128) callconv(.C) i32 {
return @enumToInt(comparef.cmpf2(f128, SparcFCMP, a.*, b.*)); return @intFromEnum(comparef.cmpf2(f128, SparcFCMP, a.*, b.*));
} }
fn _Qp_feq(a: *const f128, b: *const f128) callconv(.C) bool { fn _Qp_feq(a: *const f128, b: *const f128) callconv(.C) bool {
return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) == .Equal; return @enumFromInt(SparcFCMP, _Qp_cmp(a, b)) == .Equal;
} }
fn _Qp_fne(a: *const f128, b: *const f128) callconv(.C) bool { fn _Qp_fne(a: *const f128, b: *const f128) callconv(.C) bool {
return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) != .Equal; return @enumFromInt(SparcFCMP, _Qp_cmp(a, b)) != .Equal;
} }
fn _Qp_flt(a: *const f128, b: *const f128) callconv(.C) bool { fn _Qp_flt(a: *const f128, b: *const f128) callconv(.C) bool {
return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) == .Less; return @enumFromInt(SparcFCMP, _Qp_cmp(a, b)) == .Less;
} }
fn _Qp_fgt(a: *const f128, b: *const f128) callconv(.C) bool { fn _Qp_fgt(a: *const f128, b: *const f128) callconv(.C) bool {
return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) == .Greater; return @enumFromInt(SparcFCMP, _Qp_cmp(a, b)) == .Greater;
} }
fn _Qp_fge(a: *const f128, b: *const f128) callconv(.C) bool { fn _Qp_fge(a: *const f128, b: *const f128) callconv(.C) bool {
return switch (@intToEnum(SparcFCMP, _Qp_cmp(a, b))) { return switch (@enumFromInt(SparcFCMP, _Qp_cmp(a, b))) {
.Equal, .Greater => true, .Equal, .Greater => true,
.Less, .Unordered => false, .Less, .Unordered => false,
}; };
} }
fn _Qp_fle(a: *const f128, b: *const f128) callconv(.C) bool { fn _Qp_fle(a: *const f128, b: *const f128) callconv(.C) bool {
return switch (@intToEnum(SparcFCMP, _Qp_cmp(a, b))) { return switch (@enumFromInt(SparcFCMP, _Qp_cmp(a, b))) {
.Equal, .Less => true, .Equal, .Less => true,
.Greater, .Unordered => false, .Greater, .Unordered => false,
}; };

View file

@ -20,7 +20,7 @@ comptime {
/// Note that this matches the definition of `__lexf2`, `__eqxf2`, `__nexf2`, `__cmpxf2`, /// Note that this matches the definition of `__lexf2`, `__eqxf2`, `__nexf2`, `__cmpxf2`,
/// and `__ltxf2`. /// and `__ltxf2`.
fn __cmpxf2(a: f80, b: f80) callconv(.C) i32 { fn __cmpxf2(a: f80, b: f80) callconv(.C) i32 {
return @enumToInt(comparef.cmp_f80(comparef.LE, a, b)); return @intFromEnum(comparef.cmp_f80(comparef.LE, a, b));
} }
/// "These functions return a value less than or equal to zero if neither argument is NaN, /// "These functions return a value less than or equal to zero if neither argument is NaN,

View file

@ -77,7 +77,7 @@ pub inline fn cmp_f80(comptime RT: type, a: f80, b: f80) RT {
if ((a_rep.fraction | b_rep.fraction) | ((a_rep.exp | b_rep.exp) & special_exp) == 0) if ((a_rep.fraction | b_rep.fraction) | ((a_rep.exp | b_rep.exp) & special_exp) == 0)
return .Equal; return .Equal;
if (@boolToInt(a_rep.exp == b_rep.exp) & @boolToInt(a_rep.fraction == b_rep.fraction) != 0) { if (@intFromBool(a_rep.exp == b_rep.exp) & @intFromBool(a_rep.fraction == b_rep.fraction) != 0) {
return .Equal; return .Equal;
} else if (a_rep.exp & sign_bit != b_rep.exp & sign_bit) { } else if (a_rep.exp & sign_bit != b_rep.exp & sign_bit) {
// signs are different // signs are different
@ -109,7 +109,7 @@ pub inline fn unordcmp(comptime T: type, a: T, b: T) i32 {
const aAbs: rep_t = @bitCast(rep_t, a) & absMask; const aAbs: rep_t = @bitCast(rep_t, a) & absMask;
const bAbs: rep_t = @bitCast(rep_t, b) & absMask; const bAbs: rep_t = @bitCast(rep_t, b) & absMask;
return @boolToInt(aAbs > infRep or bAbs > infRep); return @intFromBool(aAbs > infRep or bAbs > infRep);
} }
test { test {

View file

@ -199,7 +199,7 @@ inline fn div(a: f64, b: f64) f64 {
} else if (writtenExponent < 1) { } else if (writtenExponent < 1) {
if (writtenExponent == 0) { if (writtenExponent == 0) {
// Check whether the rounded result is normal. // Check whether the rounded result is normal.
const round = @boolToInt((residual << 1) > bSignificand); const round = @intFromBool((residual << 1) > bSignificand);
// Clear the implicit bit. // Clear the implicit bit.
var absResult = quotient & significandMask; var absResult = quotient & significandMask;
// Round. // Round.
@ -213,7 +213,7 @@ inline fn div(a: f64, b: f64) f64 {
// code to round them correctly. // code to round them correctly.
return @bitCast(f64, quotientSign); return @bitCast(f64, quotientSign);
} else { } else {
const round = @boolToInt((residual << 1) > bSignificand); const round = @intFromBool((residual << 1) > bSignificand);
// Clear the implicit bit // Clear the implicit bit
var absResult = quotient & significandMask; var absResult = quotient & significandMask;
// Insert the exponent // Insert the exponent

View file

@ -179,7 +179,7 @@ inline fn div(a: f32, b: f32) f32 {
} else if (writtenExponent < 1) { } else if (writtenExponent < 1) {
if (writtenExponent == 0) { if (writtenExponent == 0) {
// Check whether the rounded result is normal. // Check whether the rounded result is normal.
const round = @boolToInt((residual << 1) > bSignificand); const round = @intFromBool((residual << 1) > bSignificand);
// Clear the implicit bit. // Clear the implicit bit.
var absResult = quotient & significandMask; var absResult = quotient & significandMask;
// Round. // Round.
@ -193,7 +193,7 @@ inline fn div(a: f32, b: f32) f32 {
// code to round them correctly. // code to round them correctly.
return @bitCast(f32, quotientSign); return @bitCast(f32, quotientSign);
} else { } else {
const round = @boolToInt((residual << 1) > bSignificand); const round = @intFromBool((residual << 1) > bSignificand);
// Clear the implicit bit // Clear the implicit bit
var absResult = quotient & significandMask; var absResult = quotient & significandMask;
// Insert the exponent // Insert the exponent

View file

@ -214,7 +214,7 @@ inline fn div(a: f128, b: f128) f128 {
} else if (writtenExponent < 1) { } else if (writtenExponent < 1) {
if (writtenExponent == 0) { if (writtenExponent == 0) {
// Check whether the rounded result is normal. // Check whether the rounded result is normal.
const round = @boolToInt((residual << 1) > bSignificand); const round = @intFromBool((residual << 1) > bSignificand);
// Clear the implicit bit. // Clear the implicit bit.
var absResult = quotient & significandMask; var absResult = quotient & significandMask;
// Round. // Round.
@ -228,7 +228,7 @@ inline fn div(a: f128, b: f128) f128 {
// code to round them correctly. // code to round them correctly.
return @bitCast(f128, quotientSign); return @bitCast(f128, quotientSign);
} else { } else {
const round = @boolToInt((residual << 1) >= bSignificand); const round = @intFromBool((residual << 1) >= bSignificand);
// Clear the implicit bit // Clear the implicit bit
var absResult = quotient & significandMask; var absResult = quotient & significandMask;
// Insert the exponent // Insert the exponent

View file

@ -195,7 +195,7 @@ pub fn __divxf3(a: f80, b: f80) callconv(.C) f80 {
// code to round them correctly. // code to round them correctly.
return @bitCast(T, quotientSign); return @bitCast(T, quotientSign);
} else { } else {
const round = @boolToInt(residual > (bSignificand >> 1)); const round = @intFromBool(residual > (bSignificand >> 1));
// Insert the exponent // Insert the exponent
var absResult = quotient | (@intCast(Z, writtenExponent) << significandBits); var absResult = quotient | (@intCast(Z, writtenExponent) << significandBits);
// Round // Round

View file

@ -74,12 +74,12 @@ pub fn expf(x_: f32) callconv(.C) f32 {
if (hx > 0x3EB17218) { if (hx > 0x3EB17218) {
// |x| > 1.5 * ln2 // |x| > 1.5 * ln2
if (hx > 0x3F851592) { if (hx > 0x3F851592) {
k = @floatToInt(i32, invln2 * x + half[@intCast(usize, sign)]); k = @intFromFloat(i32, invln2 * x + half[@intCast(usize, sign)]);
} else { } else {
k = 1 - sign - sign; k = 1 - sign - sign;
} }
const fk = @intToFloat(f32, k); const fk = @floatFromInt(f32, k);
hi = x - fk * ln2hi; hi = x - fk * ln2hi;
lo = fk * ln2lo; lo = fk * ln2lo;
x = hi - lo; x = hi - lo;
@ -157,12 +157,12 @@ pub fn exp(x_: f64) callconv(.C) f64 {
if (hx > 0x3FD62E42) { if (hx > 0x3FD62E42) {
// |x| >= 1.5 * ln2 // |x| >= 1.5 * ln2
if (hx > 0x3FF0A2B2) { if (hx > 0x3FF0A2B2) {
k = @floatToInt(i32, invln2 * x + half[@intCast(usize, sign)]); k = @intFromFloat(i32, invln2 * x + half[@intCast(usize, sign)]);
} else { } else {
k = 1 - sign - sign; k = 1 - sign - sign;
} }
const dk = @intToFloat(f64, k); const dk = @floatFromInt(f64, k);
hi = x - dk * ln2hi; hi = x - dk * ln2hi;
lo = dk * ln2lo; lo = dk * ln2lo;
x = hi - lo; x = hi - lo;

View file

@ -32,7 +32,7 @@ pub fn __exp2h(x: f16) callconv(.C) f16 {
pub fn exp2f(x: f32) callconv(.C) f32 { pub fn exp2f(x: f32) callconv(.C) f32 {
const tblsiz = @intCast(u32, exp2ft.len); const tblsiz = @intCast(u32, exp2ft.len);
const redux: f32 = 0x1.8p23 / @intToFloat(f32, tblsiz); const redux: f32 = 0x1.8p23 / @floatFromInt(f32, tblsiz);
const P1: f32 = 0x1.62e430p-1; const P1: f32 = 0x1.62e430p-1;
const P2: f32 = 0x1.ebfbe0p-3; const P2: f32 = 0x1.ebfbe0p-3;
const P3: f32 = 0x1.c6b348p-5; const P3: f32 = 0x1.c6b348p-5;
@ -89,7 +89,7 @@ pub fn exp2f(x: f32) callconv(.C) f32 {
pub fn exp2(x: f64) callconv(.C) f64 { pub fn exp2(x: f64) callconv(.C) f64 {
const tblsiz: u32 = @intCast(u32, exp2dt.len / 2); const tblsiz: u32 = @intCast(u32, exp2dt.len / 2);
const redux: f64 = 0x1.8p52 / @intToFloat(f64, tblsiz); const redux: f64 = 0x1.8p52 / @floatFromInt(f64, tblsiz);
const P1: f64 = 0x1.62e42fefa39efp-1; const P1: f64 = 0x1.62e42fefa39efp-1;
const P2: f64 = 0x1.ebfbdff82c575p-3; const P2: f64 = 0x1.ebfbdff82c575p-3;
const P3: f64 = 0x1.c6b08d704a0a6p-5; const P3: f64 = 0x1.c6b08d704a0a6p-5;

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
} }
pub fn __fixdfdi(a: f64) callconv(.C) i64 { pub fn __fixdfdi(a: f64) callconv(.C) i64 {
return floatToInt(i64, a); return intFromFloat(i64, a);
} }
fn __aeabi_d2lz(a: f64) callconv(.AAPCS) i64 { fn __aeabi_d2lz(a: f64) callconv(.AAPCS) i64 {
return floatToInt(i64, a); return intFromFloat(i64, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
} }
pub fn __fixdfsi(a: f64) callconv(.C) i32 { pub fn __fixdfsi(a: f64) callconv(.C) i32 {
return floatToInt(i32, a); return intFromFloat(i32, a);
} }
fn __aeabi_d2iz(a: f64) callconv(.AAPCS) i32 { fn __aeabi_d2iz(a: f64) callconv(.AAPCS) i32 {
return floatToInt(i32, a); return intFromFloat(i32, a);
} }

View file

@ -1,6 +1,6 @@
const builtin = @import("builtin"); const builtin = @import("builtin");
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,11 +13,11 @@ comptime {
} }
pub fn __fixdfti(a: f64) callconv(.C) i128 { pub fn __fixdfti(a: f64) callconv(.C) i128 {
return floatToInt(i128, a); return intFromFloat(i128, a);
} }
const v2u64 = @Vector(2, u64); const v2u64 = @Vector(2, u64);
fn __fixdfti_windows_x86_64(a: f64) callconv(.C) v2u64 { fn __fixdfti_windows_x86_64(a: f64) callconv(.C) v2u64 {
return @bitCast(v2u64, floatToInt(i128, a)); return @bitCast(v2u64, intFromFloat(i128, a));
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
} }
fn __fixhfdi(a: f16) callconv(.C) i64 { fn __fixhfdi(a: f16) callconv(.C) i64 {
return floatToInt(i64, a); return intFromFloat(i64, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
} }
fn __fixhfsi(a: f16) callconv(.C) i32 { fn __fixhfsi(a: f16) callconv(.C) i32 {
return floatToInt(i32, a); return intFromFloat(i32, a);
} }

View file

@ -1,6 +1,6 @@
const builtin = @import("builtin"); const builtin = @import("builtin");
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,11 +13,11 @@ comptime {
} }
pub fn __fixhfti(a: f16) callconv(.C) i128 { pub fn __fixhfti(a: f16) callconv(.C) i128 {
return floatToInt(i128, a); return intFromFloat(i128, a);
} }
const v2u64 = @Vector(2, u64); const v2u64 = @Vector(2, u64);
fn __fixhfti_windows_x86_64(a: f16) callconv(.C) v2u64 { fn __fixhfti_windows_x86_64(a: f16) callconv(.C) v2u64 {
return @bitCast(v2u64, floatToInt(i128, a)); return @bitCast(v2u64, intFromFloat(i128, a));
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
} }
pub fn __fixsfdi(a: f32) callconv(.C) i64 { pub fn __fixsfdi(a: f32) callconv(.C) i64 {
return floatToInt(i64, a); return intFromFloat(i64, a);
} }
fn __aeabi_f2lz(a: f32) callconv(.AAPCS) i64 { fn __aeabi_f2lz(a: f32) callconv(.AAPCS) i64 {
return floatToInt(i64, a); return intFromFloat(i64, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
} }
pub fn __fixsfsi(a: f32) callconv(.C) i32 { pub fn __fixsfsi(a: f32) callconv(.C) i32 {
return floatToInt(i32, a); return intFromFloat(i32, a);
} }
fn __aeabi_f2iz(a: f32) callconv(.AAPCS) i32 { fn __aeabi_f2iz(a: f32) callconv(.AAPCS) i32 {
return floatToInt(i32, a); return intFromFloat(i32, a);
} }

View file

@ -1,6 +1,6 @@
const builtin = @import("builtin"); const builtin = @import("builtin");
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,11 +13,11 @@ comptime {
} }
pub fn __fixsfti(a: f32) callconv(.C) i128 { pub fn __fixsfti(a: f32) callconv(.C) i128 {
return floatToInt(i128, a); return intFromFloat(i128, a);
} }
const v2u64 = @Vector(2, u64); const v2u64 = @Vector(2, u64);
fn __fixsfti_windows_x86_64(a: f32) callconv(.C) v2u64 { fn __fixsfti_windows_x86_64(a: f32) callconv(.C) v2u64 {
return @bitCast(v2u64, floatToInt(i128, a)); return @bitCast(v2u64, intFromFloat(i128, a));
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
} }
pub fn __fixtfdi(a: f128) callconv(.C) i64 { pub fn __fixtfdi(a: f128) callconv(.C) i64 {
return floatToInt(i64, a); return intFromFloat(i64, a);
} }
fn _Qp_qtox(a: *const f128) callconv(.C) i64 { fn _Qp_qtox(a: *const f128) callconv(.C) i64 {
return floatToInt(i64, a.*); return intFromFloat(i64, a.*);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
} }
pub fn __fixtfsi(a: f128) callconv(.C) i32 { pub fn __fixtfsi(a: f128) callconv(.C) i32 {
return floatToInt(i32, a); return intFromFloat(i32, a);
} }
fn _Qp_qtoi(a: *const f128) callconv(.C) i32 { fn _Qp_qtoi(a: *const f128) callconv(.C) i32 {
return floatToInt(i32, a.*); return intFromFloat(i32, a.*);
} }

View file

@ -1,6 +1,6 @@
const builtin = @import("builtin"); const builtin = @import("builtin");
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -15,11 +15,11 @@ comptime {
} }
pub fn __fixtfti(a: f128) callconv(.C) i128 { pub fn __fixtfti(a: f128) callconv(.C) i128 {
return floatToInt(i128, a); return intFromFloat(i128, a);
} }
const v2u64 = @Vector(2, u64); const v2u64 = @Vector(2, u64);
fn __fixtfti_windows_x86_64(a: f128) callconv(.C) v2u64 { fn __fixtfti_windows_x86_64(a: f128) callconv(.C) v2u64 {
return @bitCast(v2u64, floatToInt(i128, a)); return @bitCast(v2u64, intFromFloat(i128, a));
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
} }
pub fn __fixunsdfdi(a: f64) callconv(.C) u64 { pub fn __fixunsdfdi(a: f64) callconv(.C) u64 {
return floatToInt(u64, a); return intFromFloat(u64, a);
} }
fn __aeabi_d2ulz(a: f64) callconv(.AAPCS) u64 { fn __aeabi_d2ulz(a: f64) callconv(.AAPCS) u64 {
return floatToInt(u64, a); return intFromFloat(u64, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
} }
pub fn __fixunsdfsi(a: f64) callconv(.C) u32 { pub fn __fixunsdfsi(a: f64) callconv(.C) u32 {
return floatToInt(u32, a); return intFromFloat(u32, a);
} }
fn __aeabi_d2uiz(a: f64) callconv(.AAPCS) u32 { fn __aeabi_d2uiz(a: f64) callconv(.AAPCS) u32 {
return floatToInt(u32, a); return intFromFloat(u32, a);
} }

View file

@ -1,6 +1,6 @@
const builtin = @import("builtin"); const builtin = @import("builtin");
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,11 +13,11 @@ comptime {
} }
pub fn __fixunsdfti(a: f64) callconv(.C) u128 { pub fn __fixunsdfti(a: f64) callconv(.C) u128 {
return floatToInt(u128, a); return intFromFloat(u128, a);
} }
const v2u64 = @Vector(2, u64); const v2u64 = @Vector(2, u64);
fn __fixunsdfti_windows_x86_64(a: f64) callconv(.C) v2u64 { fn __fixunsdfti_windows_x86_64(a: f64) callconv(.C) v2u64 {
return @bitCast(v2u64, floatToInt(u128, a)); return @bitCast(v2u64, intFromFloat(u128, a));
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
} }
fn __fixunshfdi(a: f16) callconv(.C) u64 { fn __fixunshfdi(a: f16) callconv(.C) u64 {
return floatToInt(u64, a); return intFromFloat(u64, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
} }
fn __fixunshfsi(a: f16) callconv(.C) u32 { fn __fixunshfsi(a: f16) callconv(.C) u32 {
return floatToInt(u32, a); return intFromFloat(u32, a);
} }

View file

@ -1,6 +1,6 @@
const builtin = @import("builtin"); const builtin = @import("builtin");
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,11 +13,11 @@ comptime {
} }
pub fn __fixunshfti(a: f16) callconv(.C) u128 { pub fn __fixunshfti(a: f16) callconv(.C) u128 {
return floatToInt(u128, a); return intFromFloat(u128, a);
} }
const v2u64 = @Vector(2, u64); const v2u64 = @Vector(2, u64);
fn __fixunshfti_windows_x86_64(a: f16) callconv(.C) v2u64 { fn __fixunshfti_windows_x86_64(a: f16) callconv(.C) v2u64 {
return @bitCast(v2u64, floatToInt(u128, a)); return @bitCast(v2u64, intFromFloat(u128, a));
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
} }
pub fn __fixunssfdi(a: f32) callconv(.C) u64 { pub fn __fixunssfdi(a: f32) callconv(.C) u64 {
return floatToInt(u64, a); return intFromFloat(u64, a);
} }
fn __aeabi_f2ulz(a: f32) callconv(.AAPCS) u64 { fn __aeabi_f2ulz(a: f32) callconv(.AAPCS) u64 {
return floatToInt(u64, a); return intFromFloat(u64, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
} }
pub fn __fixunssfsi(a: f32) callconv(.C) u32 { pub fn __fixunssfsi(a: f32) callconv(.C) u32 {
return floatToInt(u32, a); return intFromFloat(u32, a);
} }
fn __aeabi_f2uiz(a: f32) callconv(.AAPCS) u32 { fn __aeabi_f2uiz(a: f32) callconv(.AAPCS) u32 {
return floatToInt(u32, a); return intFromFloat(u32, a);
} }

View file

@ -1,6 +1,6 @@
const builtin = @import("builtin"); const builtin = @import("builtin");
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,11 +13,11 @@ comptime {
} }
pub fn __fixunssfti(a: f32) callconv(.C) u128 { pub fn __fixunssfti(a: f32) callconv(.C) u128 {
return floatToInt(u128, a); return intFromFloat(u128, a);
} }
const v2u64 = @Vector(2, u64); const v2u64 = @Vector(2, u64);
fn __fixunssfti_windows_x86_64(a: f32) callconv(.C) v2u64 { fn __fixunssfti_windows_x86_64(a: f32) callconv(.C) v2u64 {
return @bitCast(v2u64, floatToInt(u128, a)); return @bitCast(v2u64, intFromFloat(u128, a));
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
} }
pub fn __fixunstfdi(a: f128) callconv(.C) u64 { pub fn __fixunstfdi(a: f128) callconv(.C) u64 {
return floatToInt(u64, a); return intFromFloat(u64, a);
} }
fn _Qp_qtoux(a: *const f128) callconv(.C) u64 { fn _Qp_qtoux(a: *const f128) callconv(.C) u64 {
return floatToInt(u64, a.*); return intFromFloat(u64, a.*);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
} }
pub fn __fixunstfsi(a: f128) callconv(.C) u32 { pub fn __fixunstfsi(a: f128) callconv(.C) u32 {
return floatToInt(u32, a); return intFromFloat(u32, a);
} }
fn _Qp_qtoui(a: *const f128) callconv(.C) u32 { fn _Qp_qtoui(a: *const f128) callconv(.C) u32 {
return floatToInt(u32, a.*); return intFromFloat(u32, a.*);
} }

View file

@ -1,6 +1,6 @@
const builtin = @import("builtin"); const builtin = @import("builtin");
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -15,11 +15,11 @@ comptime {
} }
pub fn __fixunstfti(a: f128) callconv(.C) u128 { pub fn __fixunstfti(a: f128) callconv(.C) u128 {
return floatToInt(u128, a); return intFromFloat(u128, a);
} }
const v2u64 = @Vector(2, u64); const v2u64 = @Vector(2, u64);
fn __fixunstfti_windows_x86_64(a: f128) callconv(.C) v2u64 { fn __fixunstfti_windows_x86_64(a: f128) callconv(.C) v2u64 {
return @bitCast(v2u64, floatToInt(u128, a)); return @bitCast(v2u64, intFromFloat(u128, a));
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
} }
fn __fixunsxfdi(a: f80) callconv(.C) u64 { fn __fixunsxfdi(a: f80) callconv(.C) u64 {
return floatToInt(u64, a); return intFromFloat(u64, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
} }
fn __fixunsxfsi(a: f80) callconv(.C) u32 { fn __fixunsxfsi(a: f80) callconv(.C) u32 {
return floatToInt(u32, a); return intFromFloat(u32, a);
} }

View file

@ -1,6 +1,6 @@
const builtin = @import("builtin"); const builtin = @import("builtin");
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,11 +13,11 @@ comptime {
} }
pub fn __fixunsxfti(a: f80) callconv(.C) u128 { pub fn __fixunsxfti(a: f80) callconv(.C) u128 {
return floatToInt(u128, a); return intFromFloat(u128, a);
} }
const v2u64 = @Vector(2, u64); const v2u64 = @Vector(2, u64);
fn __fixunsxfti_windows_x86_64(a: f80) callconv(.C) v2u64 { fn __fixunsxfti_windows_x86_64(a: f80) callconv(.C) v2u64 {
return @bitCast(v2u64, floatToInt(u128, a)); return @bitCast(v2u64, intFromFloat(u128, a));
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
} }
fn __fixxfdi(a: f80) callconv(.C) i64 { fn __fixxfdi(a: f80) callconv(.C) i64 {
return floatToInt(i64, a); return intFromFloat(i64, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
} }
fn __fixxfsi(a: f80) callconv(.C) i32 { fn __fixxfsi(a: f80) callconv(.C) i32 {
return floatToInt(i32, a); return intFromFloat(i32, a);
} }

View file

@ -1,6 +1,6 @@
const builtin = @import("builtin"); const builtin = @import("builtin");
const common = @import("./common.zig"); const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt; const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,11 +13,11 @@ comptime {
} }
pub fn __fixxfti(a: f80) callconv(.C) i128 { pub fn __fixxfti(a: f80) callconv(.C) i128 {
return floatToInt(i128, a); return intFromFloat(i128, a);
} }
const v2u64 = @Vector(2, u64); const v2u64 = @Vector(2, u64);
fn __fixxfti_windows_x86_64(a: f80) callconv(.C) v2u64 { fn __fixxfti_windows_x86_64(a: f80) callconv(.C) v2u64 {
return @bitCast(v2u64, floatToInt(i128, a)); return @bitCast(v2u64, intFromFloat(i128, a));
} }

View file

@ -1,7 +1,7 @@
const Int = @import("std").meta.Int; const Int = @import("std").meta.Int;
const math = @import("std").math; const math = @import("std").math;
pub fn intToFloat(comptime T: type, x: anytype) T { pub fn floatFromInt(comptime T: type, x: anytype) T {
if (x == 0) return 0; if (x == 0) return 0;
// Various constants whose values follow from the type parameters. // Various constants whose values follow from the type parameters.
@ -38,7 +38,7 @@ pub fn intToFloat(comptime T: type, x: anytype) T {
result = @intCast(uT, (abs_val >> (shift_amt - 1))) ^ (implicit_bit << 1); result = @intCast(uT, (abs_val >> (shift_amt - 1))) ^ (implicit_bit << 1);
// Round result, including round-to-even for exact ties // Round result, including round-to-even for exact ties
result = ((result + 1) >> 1) & ~@as(uT, @boolToInt(exact_tie)); result = ((result + 1) >> 1) & ~@as(uT, @intFromBool(exact_tie));
} }
// Compute exponent // Compute exponent
@ -54,5 +54,5 @@ pub fn intToFloat(comptime T: type, x: anytype) T {
} }
test { test {
_ = @import("int_to_float_test.zig"); _ = @import("float_from_int_test.zig");
} }

View file

@ -812,25 +812,25 @@ test "conversion to f32" {
test "conversion to f80" { test "conversion to f80" {
if (std.debug.runtime_safety) return error.SkipZigTest; if (std.debug.runtime_safety) return error.SkipZigTest;
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
try testing.expect(intToFloat(f80, @as(i80, -12)) == -12); try testing.expect(floatFromInt(f80, @as(i80, -12)) == -12);
try testing.expect(@floatToInt(u80, intToFloat(f80, @as(u64, math.maxInt(u64)) + 0)) == math.maxInt(u64) + 0); try testing.expect(@intFromFloat(u80, floatFromInt(f80, @as(u64, math.maxInt(u64)) + 0)) == math.maxInt(u64) + 0);
try testing.expect(@floatToInt(u80, intToFloat(f80, @as(u80, math.maxInt(u64)) + 1)) == math.maxInt(u64) + 1); try testing.expect(@intFromFloat(u80, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 1)) == math.maxInt(u64) + 1);
try testing.expect(intToFloat(f80, @as(u32, 0)) == 0.0); try testing.expect(floatFromInt(f80, @as(u32, 0)) == 0.0);
try testing.expect(intToFloat(f80, @as(u32, 1)) == 1.0); try testing.expect(floatFromInt(f80, @as(u32, 1)) == 1.0);
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u32, math.maxInt(u24)) + 0)) == math.maxInt(u24)); try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u32, math.maxInt(u24)) + 0)) == math.maxInt(u24));
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u64)) + 0)) == math.maxInt(u64)); try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 0)) == math.maxInt(u64));
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u64)) + 1)) == math.maxInt(u64) + 1); // Exact try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 1)) == math.maxInt(u64) + 1); // Exact
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u64)) + 2)) == math.maxInt(u64) + 1); // Rounds down try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 2)) == math.maxInt(u64) + 1); // Rounds down
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u64)) + 3)) == math.maxInt(u64) + 3); // Tie - Exact try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 3)) == math.maxInt(u64) + 3); // Tie - Exact
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u64)) + 4)) == math.maxInt(u64) + 5); // Rounds up try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 4)) == math.maxInt(u64) + 5); // Rounds up
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 0)) == math.maxInt(u65) + 1); // Rounds up try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 0)) == math.maxInt(u65) + 1); // Rounds up
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 1)) == math.maxInt(u65) + 1); // Exact try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 1)) == math.maxInt(u65) + 1); // Exact
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 2)) == math.maxInt(u65) + 1); // Rounds down try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 2)) == math.maxInt(u65) + 1); // Rounds down
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 3)) == math.maxInt(u65) + 1); // Tie - Rounds down try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 3)) == math.maxInt(u65) + 1); // Tie - Rounds down
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 4)) == math.maxInt(u65) + 5); // Rounds up try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 4)) == math.maxInt(u65) + 5); // Rounds up
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 5)) == math.maxInt(u65) + 5); // Exact try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 5)) == math.maxInt(u65) + 5); // Exact
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
} }
pub fn __floatdidf(a: i64) callconv(.C) f64 { pub fn __floatdidf(a: i64) callconv(.C) f64 {
return intToFloat(f64, a); return floatFromInt(f64, a);
} }
fn __aeabi_l2d(a: i64) callconv(.AAPCS) f64 { fn __aeabi_l2d(a: i64) callconv(.AAPCS) f64 {
return intToFloat(f64, a); return floatFromInt(f64, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
} }
fn __floatdihf(a: i64) callconv(.C) f16 { fn __floatdihf(a: i64) callconv(.C) f16 {
return intToFloat(f16, a); return floatFromInt(f16, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
} }
pub fn __floatdisf(a: i64) callconv(.C) f32 { pub fn __floatdisf(a: i64) callconv(.C) f32 {
return intToFloat(f32, a); return floatFromInt(f32, a);
} }
fn __aeabi_l2f(a: i64) callconv(.AAPCS) f32 { fn __aeabi_l2f(a: i64) callconv(.AAPCS) f32 {
return intToFloat(f32, a); return floatFromInt(f32, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
} }
pub fn __floatditf(a: i64) callconv(.C) f128 { pub fn __floatditf(a: i64) callconv(.C) f128 {
return intToFloat(f128, a); return floatFromInt(f128, a);
} }
fn _Qp_xtoq(c: *f128, a: i64) callconv(.C) void { fn _Qp_xtoq(c: *f128, a: i64) callconv(.C) void {
c.* = intToFloat(f128, a); c.* = floatFromInt(f128, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
} }
fn __floatdixf(a: i64) callconv(.C) f80 { fn __floatdixf(a: i64) callconv(.C) f80 {
return intToFloat(f80, a); return floatFromInt(f80, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
} }
pub fn __floatsidf(a: i32) callconv(.C) f64 { pub fn __floatsidf(a: i32) callconv(.C) f64 {
return intToFloat(f64, a); return floatFromInt(f64, a);
} }
fn __aeabi_i2d(a: i32) callconv(.AAPCS) f64 { fn __aeabi_i2d(a: i32) callconv(.AAPCS) f64 {
return intToFloat(f64, a); return floatFromInt(f64, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
} }
fn __floatsihf(a: i32) callconv(.C) f16 { fn __floatsihf(a: i32) callconv(.C) f16 {
return intToFloat(f16, a); return floatFromInt(f16, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
} }
pub fn __floatsisf(a: i32) callconv(.C) f32 { pub fn __floatsisf(a: i32) callconv(.C) f32 {
return intToFloat(f32, a); return floatFromInt(f32, a);
} }
fn __aeabi_i2f(a: i32) callconv(.AAPCS) f32 { fn __aeabi_i2f(a: i32) callconv(.AAPCS) f32 {
return intToFloat(f32, a); return floatFromInt(f32, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
} }
pub fn __floatsitf(a: i32) callconv(.C) f128 { pub fn __floatsitf(a: i32) callconv(.C) f128 {
return intToFloat(f128, a); return floatFromInt(f128, a);
} }
fn _Qp_itoq(c: *f128, a: i32) callconv(.C) void { fn _Qp_itoq(c: *f128, a: i32) callconv(.C) void {
c.* = intToFloat(f128, a); c.* = floatFromInt(f128, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
} }
fn __floatsixf(a: i32) callconv(.C) f80 { fn __floatsixf(a: i32) callconv(.C) f80 {
return intToFloat(f80, a); return floatFromInt(f80, a);
} }

View file

@ -1,6 +1,6 @@
const builtin = @import("builtin"); const builtin = @import("builtin");
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
} }
pub fn __floattidf(a: i128) callconv(.C) f64 { pub fn __floattidf(a: i128) callconv(.C) f64 {
return intToFloat(f64, a); return floatFromInt(f64, a);
} }
fn __floattidf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f64 { fn __floattidf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f64 {
return intToFloat(f64, @bitCast(i128, a)); return floatFromInt(f64, @bitCast(i128, a));
} }

View file

@ -1,6 +1,6 @@
const builtin = @import("builtin"); const builtin = @import("builtin");
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
} }
pub fn __floattihf(a: i128) callconv(.C) f16 { pub fn __floattihf(a: i128) callconv(.C) f16 {
return intToFloat(f16, a); return floatFromInt(f16, a);
} }
fn __floattihf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f16 { fn __floattihf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f16 {
return intToFloat(f16, @bitCast(i128, a)); return floatFromInt(f16, @bitCast(i128, a));
} }

View file

@ -1,6 +1,6 @@
const builtin = @import("builtin"); const builtin = @import("builtin");
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
} }
pub fn __floattisf(a: i128) callconv(.C) f32 { pub fn __floattisf(a: i128) callconv(.C) f32 {
return intToFloat(f32, a); return floatFromInt(f32, a);
} }
fn __floattisf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f32 { fn __floattisf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f32 {
return intToFloat(f32, @bitCast(i128, a)); return floatFromInt(f32, @bitCast(i128, a));
} }

View file

@ -1,6 +1,6 @@
const builtin = @import("builtin"); const builtin = @import("builtin");
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -15,9 +15,9 @@ comptime {
} }
pub fn __floattitf(a: i128) callconv(.C) f128 { pub fn __floattitf(a: i128) callconv(.C) f128 {
return intToFloat(f128, a); return floatFromInt(f128, a);
} }
fn __floattitf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f128 { fn __floattitf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f128 {
return intToFloat(f128, @bitCast(i128, a)); return floatFromInt(f128, @bitCast(i128, a));
} }

View file

@ -1,6 +1,6 @@
const builtin = @import("builtin"); const builtin = @import("builtin");
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
} }
pub fn __floattixf(a: i128) callconv(.C) f80 { pub fn __floattixf(a: i128) callconv(.C) f80 {
return intToFloat(f80, a); return floatFromInt(f80, a);
} }
fn __floattixf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f80 { fn __floattixf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f80 {
return intToFloat(f80, @bitCast(i128, a)); return floatFromInt(f80, @bitCast(i128, a));
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
} }
pub fn __floatundidf(a: u64) callconv(.C) f64 { pub fn __floatundidf(a: u64) callconv(.C) f64 {
return intToFloat(f64, a); return floatFromInt(f64, a);
} }
fn __aeabi_ul2d(a: u64) callconv(.AAPCS) f64 { fn __aeabi_ul2d(a: u64) callconv(.AAPCS) f64 {
return intToFloat(f64, a); return floatFromInt(f64, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
} }
fn __floatundihf(a: u64) callconv(.C) f16 { fn __floatundihf(a: u64) callconv(.C) f16 {
return intToFloat(f16, a); return floatFromInt(f16, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
} }
pub fn __floatundisf(a: u64) callconv(.C) f32 { pub fn __floatundisf(a: u64) callconv(.C) f32 {
return intToFloat(f32, a); return floatFromInt(f32, a);
} }
fn __aeabi_ul2f(a: u64) callconv(.AAPCS) f32 { fn __aeabi_ul2f(a: u64) callconv(.AAPCS) f32 {
return intToFloat(f32, a); return floatFromInt(f32, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
} }
pub fn __floatunditf(a: u64) callconv(.C) f128 { pub fn __floatunditf(a: u64) callconv(.C) f128 {
return intToFloat(f128, a); return floatFromInt(f128, a);
} }
fn _Qp_uxtoq(c: *f128, a: u64) callconv(.C) void { fn _Qp_uxtoq(c: *f128, a: u64) callconv(.C) void {
c.* = intToFloat(f128, a); c.* = floatFromInt(f128, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
} }
fn __floatundixf(a: u64) callconv(.C) f80 { fn __floatundixf(a: u64) callconv(.C) f80 {
return intToFloat(f80, a); return floatFromInt(f80, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
} }
pub fn __floatunsidf(a: u32) callconv(.C) f64 { pub fn __floatunsidf(a: u32) callconv(.C) f64 {
return intToFloat(f64, a); return floatFromInt(f64, a);
} }
fn __aeabi_ui2d(a: u32) callconv(.AAPCS) f64 { fn __aeabi_ui2d(a: u32) callconv(.AAPCS) f64 {
return intToFloat(f64, a); return floatFromInt(f64, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
} }
pub fn __floatunsihf(a: u32) callconv(.C) f16 { pub fn __floatunsihf(a: u32) callconv(.C) f16 {
return intToFloat(f16, a); return floatFromInt(f16, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
} }
pub fn __floatunsisf(a: u32) callconv(.C) f32 { pub fn __floatunsisf(a: u32) callconv(.C) f32 {
return intToFloat(f32, a); return floatFromInt(f32, a);
} }
fn __aeabi_ui2f(a: u32) callconv(.AAPCS) f32 { fn __aeabi_ui2f(a: u32) callconv(.AAPCS) f32 {
return intToFloat(f32, a); return floatFromInt(f32, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
} }
pub fn __floatunsitf(a: u32) callconv(.C) f128 { pub fn __floatunsitf(a: u32) callconv(.C) f128 {
return intToFloat(f128, a); return floatFromInt(f128, a);
} }
fn _Qp_uitoq(c: *f128, a: u32) callconv(.C) void { fn _Qp_uitoq(c: *f128, a: u32) callconv(.C) void {
c.* = intToFloat(f128, a); c.* = floatFromInt(f128, a);
} }

View file

@ -1,5 +1,5 @@
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
} }
fn __floatunsixf(a: u32) callconv(.C) f80 { fn __floatunsixf(a: u32) callconv(.C) f80 {
return intToFloat(f80, a); return floatFromInt(f80, a);
} }

View file

@ -1,6 +1,6 @@
const builtin = @import("builtin"); const builtin = @import("builtin");
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
} }
pub fn __floatuntidf(a: u128) callconv(.C) f64 { pub fn __floatuntidf(a: u128) callconv(.C) f64 {
return intToFloat(f64, a); return floatFromInt(f64, a);
} }
fn __floatuntidf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f64 { fn __floatuntidf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f64 {
return intToFloat(f64, @bitCast(u128, a)); return floatFromInt(f64, @bitCast(u128, a));
} }

View file

@ -1,6 +1,6 @@
const builtin = @import("builtin"); const builtin = @import("builtin");
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
} }
pub fn __floatuntihf(a: u128) callconv(.C) f16 { pub fn __floatuntihf(a: u128) callconv(.C) f16 {
return intToFloat(f16, a); return floatFromInt(f16, a);
} }
fn __floatuntihf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f16 { fn __floatuntihf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f16 {
return intToFloat(f16, @bitCast(u128, a)); return floatFromInt(f16, @bitCast(u128, a));
} }

View file

@ -1,6 +1,6 @@
const builtin = @import("builtin"); const builtin = @import("builtin");
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
} }
pub fn __floatuntisf(a: u128) callconv(.C) f32 { pub fn __floatuntisf(a: u128) callconv(.C) f32 {
return intToFloat(f32, a); return floatFromInt(f32, a);
} }
fn __floatuntisf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f32 { fn __floatuntisf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f32 {
return intToFloat(f32, @bitCast(u128, a)); return floatFromInt(f32, @bitCast(u128, a));
} }

View file

@ -1,6 +1,6 @@
const builtin = @import("builtin"); const builtin = @import("builtin");
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -15,9 +15,9 @@ comptime {
} }
pub fn __floatuntitf(a: u128) callconv(.C) f128 { pub fn __floatuntitf(a: u128) callconv(.C) f128 {
return intToFloat(f128, a); return floatFromInt(f128, a);
} }
fn __floatuntitf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f128 { fn __floatuntitf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f128 {
return intToFloat(f128, @bitCast(u128, a)); return floatFromInt(f128, @bitCast(u128, a));
} }

View file

@ -1,6 +1,6 @@
const builtin = @import("builtin"); const builtin = @import("builtin");
const common = @import("./common.zig"); const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat; const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic; pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
} }
pub fn __floatuntixf(a: u128) callconv(.C) f80 { pub fn __floatuntixf(a: u128) callconv(.C) f80 {
return intToFloat(f80, a); return floatFromInt(f80, a);
} }
fn __floatuntixf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f80 { fn __floatuntixf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f80 {
return intToFloat(f80, @bitCast(u128, a)); return floatFromInt(f80, @bitCast(u128, a));
} }

View file

@ -18,7 +18,7 @@ comptime {
/// "These functions return a value greater than or equal to zero if neither /// "These functions return a value greater than or equal to zero if neither
/// argument is NaN, and a is greater than or equal to b." /// argument is NaN, and a is greater than or equal to b."
pub fn __gedf2(a: f64, b: f64) callconv(.C) i32 { pub fn __gedf2(a: f64, b: f64) callconv(.C) i32 {
return @enumToInt(comparef.cmpf2(f64, comparef.GE, a, b)); return @intFromEnum(comparef.cmpf2(f64, comparef.GE, a, b));
} }
/// "These functions return a value greater than zero if neither argument is NaN, /// "These functions return a value greater than zero if neither argument is NaN,
@ -28,9 +28,9 @@ pub fn __gtdf2(a: f64, b: f64) callconv(.C) i32 {
} }
fn __aeabi_dcmpge(a: f64, b: f64) callconv(.AAPCS) i32 { fn __aeabi_dcmpge(a: f64, b: f64) callconv(.AAPCS) i32 {
return @boolToInt(comparef.cmpf2(f64, comparef.GE, a, b) != .Less); return @intFromBool(comparef.cmpf2(f64, comparef.GE, a, b) != .Less);
} }
fn __aeabi_dcmpgt(a: f64, b: f64) callconv(.AAPCS) i32 { fn __aeabi_dcmpgt(a: f64, b: f64) callconv(.AAPCS) i32 {
return @boolToInt(comparef.cmpf2(f64, comparef.GE, a, b) == .Greater); return @intFromBool(comparef.cmpf2(f64, comparef.GE, a, b) == .Greater);
} }

View file

@ -13,7 +13,7 @@ comptime {
/// "These functions return a value greater than or equal to zero if neither /// "These functions return a value greater than or equal to zero if neither
/// argument is NaN, and a is greater than or equal to b." /// argument is NaN, and a is greater than or equal to b."
pub fn __gehf2(a: f16, b: f16) callconv(.C) i32 { pub fn __gehf2(a: f16, b: f16) callconv(.C) i32 {
return @enumToInt(comparef.cmpf2(f16, comparef.GE, a, b)); return @intFromEnum(comparef.cmpf2(f16, comparef.GE, a, b));
} }
/// "These functions return a value greater than zero if neither argument is NaN, /// "These functions return a value greater than zero if neither argument is NaN,

View file

@ -18,7 +18,7 @@ comptime {
/// "These functions return a value greater than or equal to zero if neither /// "These functions return a value greater than or equal to zero if neither
/// argument is NaN, and a is greater than or equal to b." /// argument is NaN, and a is greater than or equal to b."
pub fn __gesf2(a: f32, b: f32) callconv(.C) i32 { pub fn __gesf2(a: f32, b: f32) callconv(.C) i32 {
return @enumToInt(comparef.cmpf2(f32, comparef.GE, a, b)); return @intFromEnum(comparef.cmpf2(f32, comparef.GE, a, b));
} }
/// "These functions return a value greater than zero if neither argument is NaN, /// "These functions return a value greater than zero if neither argument is NaN,
@ -28,9 +28,9 @@ pub fn __gtsf2(a: f32, b: f32) callconv(.C) i32 {
} }
fn __aeabi_fcmpge(a: f32, b: f32) callconv(.AAPCS) i32 { fn __aeabi_fcmpge(a: f32, b: f32) callconv(.AAPCS) i32 {
return @boolToInt(comparef.cmpf2(f32, comparef.GE, a, b) != .Less); return @intFromBool(comparef.cmpf2(f32, comparef.GE, a, b) != .Less);
} }
fn __aeabi_fcmpgt(a: f32, b: f32) callconv(.AAPCS) i32 { fn __aeabi_fcmpgt(a: f32, b: f32) callconv(.AAPCS) i32 {
return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) == .Greater); return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) == .Greater);
} }

View file

@ -20,7 +20,7 @@ comptime {
/// "These functions return a value greater than or equal to zero if neither /// "These functions return a value greater than or equal to zero if neither
/// argument is NaN, and a is greater than or equal to b." /// argument is NaN, and a is greater than or equal to b."
fn __getf2(a: f128, b: f128) callconv(.C) i32 { fn __getf2(a: f128, b: f128) callconv(.C) i32 {
return @enumToInt(comparef.cmpf2(f128, comparef.GE, a, b)); return @intFromEnum(comparef.cmpf2(f128, comparef.GE, a, b));
} }
/// "These functions return a value greater than zero if neither argument is NaN, /// "These functions return a value greater than zero if neither argument is NaN,

View file

@ -9,7 +9,7 @@ comptime {
} }
fn __gexf2(a: f80, b: f80) callconv(.C) i32 { fn __gexf2(a: f80, b: f80) callconv(.C) i32 {
return @enumToInt(comparef.cmp_f80(comparef.GE, a, b)); return @intFromEnum(comparef.cmp_f80(comparef.GE, a, b));
} }
fn __gtxf2(a: f80, b: f80) callconv(.C) i32 { fn __gtxf2(a: f80, b: f80) callconv(.C) i32 {

View file

@ -2,7 +2,7 @@ const Int = @import("std").meta.Int;
const math = @import("std").math; const math = @import("std").math;
const Log2Int = math.Log2Int; const Log2Int = math.Log2Int;
pub inline fn floatToInt(comptime I: type, a: anytype) I { pub inline fn intFromFloat(comptime I: type, a: anytype) I {
const F = @TypeOf(a); const F = @TypeOf(a);
const float_bits = @typeInfo(F).Float.bits; const float_bits = @typeInfo(F).Float.bits;
const int_bits = @typeInfo(I).Int.bits; const int_bits = @typeInfo(I).Int.bits;
@ -51,5 +51,5 @@ pub inline fn floatToInt(comptime I: type, a: anytype) I {
} }
test { test {
_ = @import("float_to_int_test.zig"); _ = @import("int_from_float_test.zig");
} }

View file

@ -77,7 +77,7 @@ pub fn logf(x_: f32) callconv(.C) f32 {
const t2 = z * (Lg1 + w * Lg3); const t2 = z * (Lg1 + w * Lg3);
const R = t2 + t1; const R = t2 + t1;
const hfsq = 0.5 * f * f; const hfsq = 0.5 * f * f;
const dk = @intToFloat(f32, k); const dk = @floatFromInt(f32, k);
return s * (hfsq + R) + dk * ln2_lo - hfsq + f + dk * ln2_hi; return s * (hfsq + R) + dk * ln2_lo - hfsq + f + dk * ln2_hi;
} }
@ -133,7 +133,7 @@ pub fn log(x_: f64) callconv(.C) f64 {
const t1 = w * (Lg2 + w * (Lg4 + w * Lg6)); const t1 = w * (Lg2 + w * (Lg4 + w * Lg6));
const t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7))); const t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));
const R = t2 + t1; const R = t2 + t1;
const dk = @intToFloat(f64, k); const dk = @floatFromInt(f64, k);
return s * (hfsq + R) + dk * ln2_lo - hfsq + f + dk * ln2_hi; return s * (hfsq + R) + dk * ln2_lo - hfsq + f + dk * ln2_hi;
} }

View file

@ -86,7 +86,7 @@ pub fn log10f(x_: f32) callconv(.C) f32 {
u &= 0xFFFFF000; u &= 0xFFFFF000;
hi = @bitCast(f32, u); hi = @bitCast(f32, u);
const lo = f - hi - hfsq + s * (hfsq + R); const lo = f - hi - hfsq + s * (hfsq + R);
const dk = @intToFloat(f32, k); const dk = @floatFromInt(f32, k);
return dk * log10_2lo + (lo + hi) * ivln10lo + lo * ivln10hi + hi * ivln10hi + dk * log10_2hi; return dk * log10_2lo + (lo + hi) * ivln10lo + lo * ivln10hi + hi * ivln10hi + dk * log10_2hi;
} }
@ -154,7 +154,7 @@ pub fn log10(x_: f64) callconv(.C) f64 {
// val_hi + val_lo ~ log10(1 + f) + k * log10(2) // val_hi + val_lo ~ log10(1 + f) + k * log10(2)
var val_hi = hi * ivln10hi; var val_hi = hi * ivln10hi;
const dk = @intToFloat(f64, k); const dk = @floatFromInt(f64, k);
const y = dk * log10_2hi; const y = dk * log10_2hi;
var val_lo = dk * log10_2lo + (lo + hi) * ivln10lo + lo * ivln10hi; var val_lo = dk * log10_2lo + (lo + hi) * ivln10lo + lo * ivln10hi;

View file

@ -84,7 +84,7 @@ pub fn log2f(x_: f32) callconv(.C) f32 {
u &= 0xFFFFF000; u &= 0xFFFFF000;
hi = @bitCast(f32, u); hi = @bitCast(f32, u);
const lo = f - hi - hfsq + s * (hfsq + R); const lo = f - hi - hfsq + s * (hfsq + R);
return (lo + hi) * ivln2lo + lo * ivln2hi + hi * ivln2hi + @intToFloat(f32, k); return (lo + hi) * ivln2lo + lo * ivln2hi + hi * ivln2hi + @floatFromInt(f32, k);
} }
pub fn log2(x_: f64) callconv(.C) f64 { pub fn log2(x_: f64) callconv(.C) f64 {
@ -150,7 +150,7 @@ pub fn log2(x_: f64) callconv(.C) f64 {
var val_lo = (lo + hi) * ivln2lo + lo * ivln2hi; var val_lo = (lo + hi) * ivln2lo + lo * ivln2hi;
// spadd(val_hi, val_lo, y) // spadd(val_hi, val_lo, y)
const y = @intToFloat(f64, k); const y = @floatFromInt(f64, k);
const ww = y + val_hi; const ww = y + val_hi;
val_lo += (y - ww) + val_hi; val_lo += (y - ww) + val_hi;
val_hi = ww; val_hi = ww;

View file

@ -8,7 +8,7 @@ comptime {
pub fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8 { pub fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8 {
@setRuntimeSafety(false); @setRuntimeSafety(false);
if (@ptrToInt(dest) < @ptrToInt(src)) { if (@intFromPtr(dest) < @intFromPtr(src)) {
var index: usize = 0; var index: usize = 0;
while (index != n) : (index += 1) { while (index != n) : (index += 1) {
dest.?[index] = src.?[index]; dest.?[index] = src.?[index];

View file

@ -126,7 +126,7 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T {
// Otherwise, shift the significand of the result so that the round // Otherwise, shift the significand of the result so that the round
// bit is the high bit of productLo. // bit is the high bit of productLo.
const sticky = wideShrWithTruncation(ZSignificand, &productHi, &productLo, shift); const sticky = wideShrWithTruncation(ZSignificand, &productHi, &productLo, shift);
productLo |= @boolToInt(sticky); productLo |= @intFromBool(sticky);
result = productHi; result = productHi;
// We include the integer bit so that rounding will carry to the exponent, // We include the integer bit so that rounding will carry to the exponent,

View file

@ -36,7 +36,7 @@ const __isPlatformVersionAtLeast = if (builtin.os.tag.isDarwin()) struct {
.platform = platform, .platform = platform,
.version = constructVersion(major, minor, subminor), .version = constructVersion(major, minor, subminor),
}; };
return @boolToInt(_availability_version_check(1, &[_]dyld_build_version_t{build_version})); return @intFromBool(_availability_version_check(1, &[_]dyld_build_version_t{build_version}));
} }
// _availability_version_check darwin API support. // _availability_version_check darwin API support.

View file

@ -9,7 +9,7 @@ fn paritydi2Naive(a: i64) i32 {
has_parity = !has_parity; has_parity = !has_parity;
x = x & (x - 1); x = x & (x - 1);
} }
return @intCast(i32, @boolToInt(has_parity)); return @intCast(i32, @intFromBool(has_parity));
} }
fn test__paritydi2(a: i64) !void { fn test__paritydi2(a: i64) !void {

View file

@ -9,7 +9,7 @@ fn paritysi2Naive(a: i32) i32 {
has_parity = !has_parity; has_parity = !has_parity;
x = x & (x - 1); x = x & (x - 1);
} }
return @intCast(i32, @boolToInt(has_parity)); return @intCast(i32, @intFromBool(has_parity));
} }
fn test__paritysi2(a: i32) !void { fn test__paritysi2(a: i32) !void {

View file

@ -9,7 +9,7 @@ fn parityti2Naive(a: i128) i32 {
has_parity = !has_parity; has_parity = !has_parity;
x = x & (x - 1); x = x & (x - 1);
} }
return @intCast(i32, @boolToInt(has_parity)); return @intCast(i32, @intFromBool(has_parity));
} }
fn test__parityti2(a: i128) !void { fn test__parityti2(a: i128) !void {

View file

@ -41,7 +41,7 @@ fn medium(ix: u32, x: f64, y: *[2]f64) i32 {
// rint(x/(pi/2)) // rint(x/(pi/2))
@"fn" = x * invpio2 + toint - toint; @"fn" = x * invpio2 + toint - toint;
n = @floatToInt(i32, @"fn"); n = @intFromFloat(i32, @"fn");
r = x - @"fn" * pio2_1; r = x - @"fn" * pio2_1;
w = @"fn" * pio2_1t; // 1st round, good to 85 bits w = @"fn" * pio2_1t; // 1st round, good to 85 bits
// Matters with directed rounding. // Matters with directed rounding.
@ -178,7 +178,7 @@ pub fn rem_pio2(x: f64, y: *[2]f64) i32 {
i = 0; i = 0;
while (i < 2) : (i += 1) { while (i < 2) : (i += 1) {
tx[U(i)] = @intToFloat(f64, @floatToInt(i32, z)); tx[U(i)] = @floatFromInt(f64, @intFromFloat(i32, z));
z = (z - tx[U(i)]) * 0x1p24; z = (z - tx[U(i)]) * 0x1p24;
} }
tx[U(i)] = z; tx[U(i)] = z;

View file

@ -295,7 +295,7 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
i += 1; i += 1;
j += 1; j += 1;
}) { }) {
f[U(i)] = if (j < 0) 0.0 else @intToFloat(f64, ipio2[U(j)]); f[U(i)] = if (j < 0) 0.0 else @floatFromInt(f64, ipio2[U(j)]);
} }
// compute q[0],q[1],...q[jk] // compute q[0],q[1],...q[jk]
@ -322,16 +322,16 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
i += 1; i += 1;
j -= 1; j -= 1;
}) { }) {
fw = @intToFloat(f64, @floatToInt(i32, 0x1p-24 * z)); fw = @floatFromInt(f64, @intFromFloat(i32, 0x1p-24 * z));
iq[U(i)] = @floatToInt(i32, z - 0x1p24 * fw); iq[U(i)] = @intFromFloat(i32, z - 0x1p24 * fw);
z = q[U(j - 1)] + fw; z = q[U(j - 1)] + fw;
} }
// compute n // compute n
z = math.scalbn(z, q0); // actual value of z z = math.scalbn(z, q0); // actual value of z
z -= 8.0 * @floor(z * 0.125); // trim off integer >= 8 z -= 8.0 * @floor(z * 0.125); // trim off integer >= 8
n = @floatToInt(i32, z); n = @intFromFloat(i32, z);
z -= @intToFloat(f64, n); z -= @floatFromInt(f64, n);
ih = 0; ih = 0;
if (q0 > 0) { // need iq[jz-1] to determine n if (q0 > 0) { // need iq[jz-1] to determine n
i = iq[U(jz - 1)] >> @intCast(u5, 24 - q0); i = iq[U(jz - 1)] >> @intCast(u5, 24 - q0);
@ -390,7 +390,7 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
i = jz + 1; i = jz + 1;
while (i <= jz + k) : (i += 1) { // add q[jz+1] to q[jz+k] while (i <= jz + k) : (i += 1) { // add q[jz+1] to q[jz+k]
f[U(jx + i)] = @intToFloat(f64, ipio2[U(jv + i)]); f[U(jx + i)] = @floatFromInt(f64, ipio2[U(jv + i)]);
j = 0; j = 0;
fw = 0; fw = 0;
while (j <= jx) : (j += 1) { while (j <= jx) : (j += 1) {
@ -414,13 +414,13 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
} else { // break z into 24-bit if necessary } else { // break z into 24-bit if necessary
z = math.scalbn(z, -q0); z = math.scalbn(z, -q0);
if (z >= 0x1p24) { if (z >= 0x1p24) {
fw = @intToFloat(f64, @floatToInt(i32, 0x1p-24 * z)); fw = @floatFromInt(f64, @intFromFloat(i32, 0x1p-24 * z));
iq[U(jz)] = @floatToInt(i32, z - 0x1p24 * fw); iq[U(jz)] = @intFromFloat(i32, z - 0x1p24 * fw);
jz += 1; jz += 1;
q0 += 24; q0 += 24;
iq[U(jz)] = @floatToInt(i32, fw); iq[U(jz)] = @intFromFloat(i32, fw);
} else { } else {
iq[U(jz)] = @floatToInt(i32, z); iq[U(jz)] = @intFromFloat(i32, z);
} }
} }
@ -428,7 +428,7 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
fw = math.scalbn(@as(f64, 1.0), q0); fw = math.scalbn(@as(f64, 1.0), q0);
i = jz; i = jz;
while (i >= 0) : (i -= 1) { while (i >= 0) : (i -= 1) {
q[U(i)] = fw * @intToFloat(f64, iq[U(i)]); q[U(i)] = fw * @floatFromInt(f64, iq[U(i)]);
fw *= 0x1p-24; fw *= 0x1p-24;
} }

View file

@ -37,7 +37,7 @@ pub fn rem_pio2f(x: f32, y: *f64) i32 {
if (ix < 0x4dc90fdb) { // |x| ~< 2^28*(pi/2), medium size if (ix < 0x4dc90fdb) { // |x| ~< 2^28*(pi/2), medium size
// Use a specialized rint() to get fn. // Use a specialized rint() to get fn.
@"fn" = @floatCast(f64, x) * invpio2 + toint - toint; @"fn" = @floatCast(f64, x) * invpio2 + toint - toint;
n = @floatToInt(i32, @"fn"); n = @intFromFloat(i32, @"fn");
y.* = x - @"fn" * pio2_1 - @"fn" * pio2_1t; y.* = x - @"fn" * pio2_1 - @"fn" * pio2_1t;
// Matters with directed rounding. // Matters with directed rounding.
if (y.* < -pio4) { if (y.* < -pio4) {

Some files were not shown because too many files have changed in this diff Show more