Logo white

Anubis / Anubis

Sign in
  • Sign in
  • Project
  • Files
  • Commits
  • Network
  • Graphs
  • Milestones
  • Issues 0
  • Merge Requests 0
  • Labels
  • Wiki
  • anubis
  • anubis_dev
  • library
  • tools
  • rationals.anubis
  • -
    e471ddee
    Alain Prouté authored
    2014-09-05 22:20:32 +0000  
    Browse Code »
rationals.anubis 482 Bytes
Edit Raw Blame History
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

                       The Anubis Project. 

                        Rational numbers. 
                        
                        
                        
public type Q:
  q(Int numerator, 
    Int denominator). 
    
public define Q
  Q x + Q y 
  =
  if x is q(xn,xd) then
  if y is q(yn,yd) then 
  q(xn*yd+xd*yn,xd*yd). 
  
public define Q
  Q x * Q y
  =
  if x is q(xn,xd) then
  if y is q(yn,yd) then 
  q(xn*yn,xd*yd).