Function setRatio [src]

Set a rational from an integer ratio.

Prototype

pub fn setRatio(self: *Rational, p: anytype, q: anytype) !void

Parameters

self: *Rational

Source

pub fn setRatio(self: *Rational, p: anytype, q: anytype) !void { try self.p.set(p); try self.q.set(q); self.p.setSign(@intFromBool(self.p.isPositive()) ^ @intFromBool(self.q.isPositive()) == 0); self.q.setSign(true); try self.reduce(); if (self.q.eqlZero()) { @panic("cannot set rational with denominator = 0"); } }