Function toFloat [src]

Convert self to float type T.

Prototype

pub fn toFloat(self: Const, comptime T: type) T

Parameters

self: ConstT: type

Source

pub fn toFloat(self: Const, comptime T: type) T { if (self.limbs.len == 0) return 0; const base = std.math.maxInt(std.math.big.Limb) + 1; var result: f128 = 0; var i: usize = self.limbs.len; while (i != 0) { i -= 1; const limb: f128 = @floatFromInt(self.limbs[i]); result = @mulAdd(f128, base, result, limb); } if (self.positive) { return @floatCast(result); } else { return @floatCast(-result); } }