All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.snapscript.tree.math.FloatCalculator Maven / Gradle / Ivy

There is a newer version: 1.4.6
Show newest version
package org.snapscript.tree.math;

import org.snapscript.core.variable.Value;
import org.snapscript.core.variable.ValueCache;

public class FloatCalculator extends IntegerCalculator {

   @Override
   public Value add(Number left, Number right) {
      float first = left.floatValue();
      float second = right.floatValue();
      
      return ValueCache.getFloat(first + second);
   }

   @Override
   public Value subtract(Number left, Number right) {
      float first = left.floatValue();
      float second = right.floatValue();
      
      return ValueCache.getFloat(first - second);
   }

   @Override
   public Value divide(Number left, Number right) {
      float first = left.floatValue();
      float second = right.floatValue();
      
      return ValueCache.getFloat(first / second);
   }

   @Override
   public Value multiply(Number left, Number right) {
      float first = left.floatValue();
      float second = right.floatValue();
      
      return ValueCache.getFloat(first * second);
   }

   @Override
   public Value modulus(Number left, Number right) {
      float first = left.floatValue();
      float second = right.floatValue();
      
      return ValueCache.getFloat(first % second);
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy