Changeset 2059


Ignore:
Timestamp:
Aug 24, 2006, 7:32:41 PM (14 years ago)
Author:
orlov
Message:
  • Max and Min functions.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/java/org/refal/plus/library/Arithm.java

    r2024 r2059  
    9898        }
    9999    }
     100   
     101    static public void Max (Expr s1, Expr s2, Result res) throws RefalException
     102    {
     103        assert s1.getLen() == 1;
     104        assert s2.getLen() == 1;
     105        try {
     106            res.assign(((BigInteger) s1.at(0)).max((BigInteger) s2.at(0)));
     107        } catch (ClassCastException e) {
     108            throw new RefalException("Arithm", "Max", "Invalid argument");
     109        }
     110    }
     111
     112    static public void Min (Expr s1, Expr s2, Result res) throws RefalException
     113    {
     114        assert s1.getLen() == 1;
     115        assert s2.getLen() == 1;
     116        try {
     117            res.assign(((BigInteger) s1.at(0)).min((BigInteger) s2.at(0)));
     118        } catch (ClassCastException e) {
     119            throw new RefalException("Arithm", "Min", "Invalid argument");
     120        }
     121    }
    100122}
Note: See TracChangeset for help on using the changeset viewer.