Commit 2e5342512f
lib/std/math/ln.zig
@@ -21,7 +21,7 @@ pub fn ln(x: var) @TypeOf(x) {
const T = @TypeOf(x);
switch (@typeId(T)) {
TypeId.ComptimeFloat => {
- return @TypeOf(1.0)(ln_64(x));
+ return @as(comptime_float, ln_64(x));
},
TypeId.Float => {
return switch (T) {
@@ -31,7 +31,7 @@ pub fn ln(x: var) @TypeOf(x) {
};
},
TypeId.ComptimeInt => {
- return @TypeOf(1)(math.floor(ln_64(@as(f64, x))));
+ return @as(comptime_int, math.floor(ln_64(@as(f64, x))));
},
TypeId.Int => {
return @as(T, math.floor(ln_64(@as(f64, x))));
lib/std/math/log.zig
@@ -23,10 +23,10 @@ pub fn log(comptime T: type, base: T, x: T) T {
const float_base = math.lossyCast(f64, base);
switch (@typeId(T)) {
TypeId.ComptimeFloat => {
- return @TypeOf(1.0)(math.ln(@as(f64, x)) / math.ln(float_base));
+ return @as(comptime_float, math.ln(@as(f64, x)) / math.ln(float_base));
},
TypeId.ComptimeInt => {
- return @TypeOf(1)(math.floor(math.ln(@as(f64, x)) / math.ln(float_base)));
+ return @as(comptime_int, math.floor(math.ln(@as(f64, x)) / math.ln(float_base)));
},
builtin.TypeId.Int => {
// TODO implement integer log without using float math
lib/std/math/log10.zig
@@ -22,7 +22,7 @@ pub fn log10(x: var) @TypeOf(x) {
const T = @TypeOf(x);
switch (@typeId(T)) {
TypeId.ComptimeFloat => {
- return @TypeOf(1.0)(log10_64(x));
+ return @as(comptime_float, log10_64(x));
},
TypeId.Float => {
return switch (T) {
@@ -32,7 +32,7 @@ pub fn log10(x: var) @TypeOf(x) {
};
},
TypeId.ComptimeInt => {
- return @TypeOf(1)(math.floor(log10_64(@as(f64, x))));
+ return @as(comptime_int, math.floor(log10_64(@as(f64, x))));
},
TypeId.Int => {
return @floatToInt(T, math.floor(log10_64(@intToFloat(f64, x))));
lib/std/math/log2.zig
@@ -22,7 +22,7 @@ pub fn log2(x: var) @TypeOf(x) {
const T = @TypeOf(x);
switch (@typeId(T)) {
TypeId.ComptimeFloat => {
- return @TypeOf(1.0)(log2_64(x));
+ return @as(comptime_float, log2_64(x));
},
TypeId.Float => {
return switch (T) {