1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-11-17 16:09:32 -08:00

Implement sin function and helper functions such as getSmallAngle and floor.

This commit is contained in:
Arthur Drobot 2017-08-01 15:36:54 -07:00
parent c7136f903a
commit 661bc170fc
4 changed files with 98 additions and 0 deletions

View File

@ -98,6 +98,11 @@ public class NaiveNumber implements NumberInterface {
return (int) Math.ceil(value);
}
@Override
public int floor() {
return (int) Math.floor(value);
}
@Override
public NumberInterface promoteTo(Class<? extends NumberInterface> toClass) {
if (toClass == this.getClass()) return this;

View File

@ -85,6 +85,12 @@ public interface NumberInterface {
*/
int ceiling();
/**
* Return the greatest integer less than or equal to the number.
* @return the greatest int >= the number, if int can hold the value.
*/
int floor();
/**
* Promotes this class to another number class.
*

View File

@ -100,6 +100,11 @@ public class PreciseNumber implements NumberInterface {
return (int) Math.ceil(value.doubleValue());
}
@Override
public int floor() {
return (int) Math.floor(value.doubleValue());
}
@Override
public NumberInterface negate() {
return new PreciseNumber(value.negate());

File diff suppressed because one or more lines are too long