| author | |
| committer | |
| log | 2e5342512f32384777ebcb0bf3dcb177b9380080 |
| tree | af77106b92cb13923c1b205c19a1408b0294e458 |
| parent | 508a8980ba7f83890cebfe8d7b51d07f00c546c5 |
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) { | ... | @@ -21,7 +21,7 @@ pub fn ln(x: var) @TypeOf(x) { |
| 21 | const T = @TypeOf(x); | 21 | const T = @TypeOf(x); |
| 22 | switch (@typeId(T)) { | 22 | switch (@typeId(T)) { |
| 23 | TypeId.ComptimeFloat => { | 23 | TypeId.ComptimeFloat => { |
| 24 | return @TypeOf(1.0)(ln_64(x)); | 24 | return @as(comptime_float, ln_64(x)); |
| 25 | }, | 25 | }, |
| 26 | TypeId.Float => { | 26 | TypeId.Float => { |
| 27 | return switch (T) { | 27 | return switch (T) { |
| ... | @@ -31,7 +31,7 @@ pub fn ln(x: var) @TypeOf(x) { | ... | @@ -31,7 +31,7 @@ pub fn ln(x: var) @TypeOf(x) { |
| 31 | }; | 31 | }; |
| 32 | }, | 32 | }, |
| 33 | TypeId.ComptimeInt => { | 33 | 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)))); |
| 35 | }, | 35 | }, |
| 36 | TypeId.Int => { | 36 | TypeId.Int => { |
| 37 | return @as(T, math.floor(ln_64(@as(f64, x)))); | 37 | 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 { | ... | @@ -23,10 +23,10 @@ pub fn log(comptime T: type, base: T, x: T) T { |
| 23 | const float_base = math.lossyCast(f64, base); | 23 | const float_base = math.lossyCast(f64, base); |
| 24 | switch (@typeId(T)) { | 24 | switch (@typeId(T)) { |
| 25 | TypeId.ComptimeFloat => { | 25 | 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)); |
| 27 | }, | 27 | }, |
| 28 | TypeId.ComptimeInt => { | 28 | 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))); |
| 30 | }, | 30 | }, |
| 31 | builtin.TypeId.Int => { | 31 | builtin.TypeId.Int => { |
| 32 | // TODO implement integer log without using float math | 32 | // 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) { | ... | @@ -22,7 +22,7 @@ pub fn log10(x: var) @TypeOf(x) { |
| 22 | const T = @TypeOf(x); | 22 | const T = @TypeOf(x); |
| 23 | switch (@typeId(T)) { | 23 | switch (@typeId(T)) { |
| 24 | TypeId.ComptimeFloat => { | 24 | TypeId.ComptimeFloat => { |
| 25 | return @TypeOf(1.0)(log10_64(x)); | 25 | return @as(comptime_float, log10_64(x)); |
| 26 | }, | 26 | }, |
| 27 | TypeId.Float => { | 27 | TypeId.Float => { |
| 28 | return switch (T) { | 28 | return switch (T) { |
| ... | @@ -32,7 +32,7 @@ pub fn log10(x: var) @TypeOf(x) { | ... | @@ -32,7 +32,7 @@ pub fn log10(x: var) @TypeOf(x) { |
| 32 | }; | 32 | }; |
| 33 | }, | 33 | }, |
| 34 | TypeId.ComptimeInt => { | 34 | 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)))); |
| 36 | }, | 36 | }, |
| 37 | TypeId.Int => { | 37 | TypeId.Int => { |
| 38 | return @floatToInt(T, math.floor(log10_64(@intToFloat(f64, x)))); | 38 | 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) { | ... | @@ -22,7 +22,7 @@ pub fn log2(x: var) @TypeOf(x) { |
| 22 | const T = @TypeOf(x); | 22 | const T = @TypeOf(x); |
| 23 | switch (@typeId(T)) { | 23 | switch (@typeId(T)) { |
| 24 | TypeId.ComptimeFloat => { | 24 | TypeId.ComptimeFloat => { |
| 25 | return @TypeOf(1.0)(log2_64(x)); | 25 | return @as(comptime_float, log2_64(x)); |
| 26 | }, | 26 | }, |
| 27 | TypeId.Float => { | 27 | TypeId.Float => { |
| 28 | return switch (T) { | 28 | return switch (T) { |