authorgravatar for isnt@haze.coolHaze Booth <isnt@haze.cool> 2020-01-03 19:57:45-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-05 02:33:23-05:00
log2e5342512f32384777ebcb0bf3dcb177b9380080
treeaf77106b92cb13923c1b205c19a1408b0294e458
parent508a8980ba7f83890cebfe8d7b51d07f00c546c5

remove @TypeOf() hacks for comptime_int/comptime_float


4 files changed, 7 insertions(+), 7 deletions(-)

lib/std/math/ln.zig+2-2
......@@ -21,7 +21,7 @@ pub fn ln(x: var) @TypeOf(x) {
2121 const T = @TypeOf(x);
2222 switch (@typeId(T)) {
2323 TypeId.ComptimeFloat => {
24 return @TypeOf(1.0)(ln_64(x));
24 return @as(comptime_float, ln_64(x));
2525 },
2626 TypeId.Float => {
2727 return switch (T) {
......@@ -31,7 +31,7 @@ pub fn ln(x: var) @TypeOf(x) {
3131 };
3232 },
3333 TypeId.ComptimeInt => {
34 return @TypeOf(1)(math.floor(ln_64(@as(f64, x))));
34 return @as(comptime_int, math.floor(ln_64(@as(f64, x))));
3535 },
3636 TypeId.Int => {
3737 return @as(T, math.floor(ln_64(@as(f64, x))));
lib/std/math/log.zig+2-2
......@@ -23,10 +23,10 @@ pub fn log(comptime T: type, base: T, x: T) T {
2323 const float_base = math.lossyCast(f64, base);
2424 switch (@typeId(T)) {
2525 TypeId.ComptimeFloat => {
26 return @TypeOf(1.0)(math.ln(@as(f64, x)) / math.ln(float_base));
26 return @as(comptime_float, math.ln(@as(f64, x)) / math.ln(float_base));
2727 },
2828 TypeId.ComptimeInt => {
29 return @TypeOf(1)(math.floor(math.ln(@as(f64, x)) / math.ln(float_base)));
29 return @as(comptime_int, math.floor(math.ln(@as(f64, x)) / math.ln(float_base)));
3030 },
3131 builtin.TypeId.Int => {
3232 // TODO implement integer log without using float math
lib/std/math/log10.zig+2-2
......@@ -22,7 +22,7 @@ pub fn log10(x: var) @TypeOf(x) {
2222 const T = @TypeOf(x);
2323 switch (@typeId(T)) {
2424 TypeId.ComptimeFloat => {
25 return @TypeOf(1.0)(log10_64(x));
25 return @as(comptime_float, log10_64(x));
2626 },
2727 TypeId.Float => {
2828 return switch (T) {
......@@ -32,7 +32,7 @@ pub fn log10(x: var) @TypeOf(x) {
3232 };
3333 },
3434 TypeId.ComptimeInt => {
35 return @TypeOf(1)(math.floor(log10_64(@as(f64, x))));
35 return @as(comptime_int, math.floor(log10_64(@as(f64, x))));
3636 },
3737 TypeId.Int => {
3838 return @floatToInt(T, math.floor(log10_64(@intToFloat(f64, x))));
lib/std/math/log2.zig+1-1
......@@ -22,7 +22,7 @@ pub fn log2(x: var) @TypeOf(x) {
2222 const T = @TypeOf(x);
2323 switch (@typeId(T)) {
2424 TypeId.ComptimeFloat => {
25 return @TypeOf(1.0)(log2_64(x));
25 return @as(comptime_float, log2_64(x));
2626 },
2727 TypeId.Float => {
2828 return switch (T) {