Function copyRatio [src]

Set a Rational directly from a ratio of two Int's.

Prototype

pub fn copyRatio(self: *Rational, a: Int, b: Int) !void

Parameters

self: *Rationala: Intb: Int

Source

pub fn copyRatio(self: *Rational, a: Int, b: Int) !void { try self.p.copy(a.toConst()); try self.q.copy(b.toConst()); self.p.setSign(@intFromBool(self.p.isPositive()) ^ @intFromBool(self.q.isPositive()) == 0); self.q.setSign(true); try self.reduce(); }