nimrat

Module for working with rational numbers (fractions)

Readme

nimrat Build Status Build Status

<:3)~~

This module implements some very basic rational arithmetic in Nim.

Example:

import nimrat

var 
  myFrac: Rational = (3,4) # the fraction 3/4
  myFrac2: Rational = (7,8) # the fraction 7/8
    
echo myFrac + myFrac2
# Prints "13 / 8"
echo myFrac * myFrac2
# Prints "21 / 32"
echo myFrac / myFrac2
# Prints "6 / 7"
echo simple((33,44)) # reduced form of a given fraction
# Prints "3 / 4"
# Note, to actually simplify, do:
var unSimple = (4,8)
unSimple.simplify # actually modifies the rational
echo unSimple
# Prints (1,2)
Need help? Read Nimble
Author:
apense
Available versions:
License: MIT

Project website Hosted docs