public final class SimpleDoubleScore extends AbstractScore<SimpleDoubleScore>
Score is based on 1 level of double constraints.
WARNING: NOT RECOMMENDED TO USE DUE TO ROUNDING ERRORS THAT CAUSE SCORE CORRUPTION.
For example, this prints false: System.out.println((0.01 + 0.05) == (0.01 + 0.02 + 0.03));
Use SimpleBigDecimalScore instead.
This class is immutable.
Score,
Serialized Form| Modifier and Type | Method and Description |
|---|---|
SimpleDoubleScore |
add(SimpleDoubleScore augment)
Returns a Score whose value is (this + augment).
|
int |
compareTo(SimpleDoubleScore other) |
SimpleDoubleScore |
divide(double divisor)
Returns a Score whose value is (this / divisor).
|
boolean |
equals(Object o) |
double |
getScore()
The total of the broken negative constraints and fulfilled positive hard constraints.
|
int |
hashCode() |
SimpleDoubleScore |
multiply(double multiplicand)
Returns a Score whose value is (this * multiplicand).
|
SimpleDoubleScore |
negate()
Returns a Score whose value is (- this).
|
static SimpleDoubleScore |
parseScore(String scoreString) |
SimpleDoubleScore |
power(double exponent)
Returns a Score whose value is (this ^ exponent).
|
SimpleDoubleScore |
subtract(SimpleDoubleScore subtrahend)
Returns a Score whose value is (this - subtrahend).
|
Number[] |
toLevelNumbers()
Returns an array of numbers representing the Score.
|
String |
toString() |
static SimpleDoubleScore |
valueOf(double score) |
buildScorePattern, buildScorePattern, isCompatibleArithmeticArgument, parseLevelAsBigDecimal, parseLevelAsDouble, parseLevelAsInt, parseLevelAsLong, parseLevelStrings, parseLevelStringspublic static SimpleDoubleScore parseScore(String scoreString)
public static SimpleDoubleScore valueOf(double score)
public double getScore()
public SimpleDoubleScore add(SimpleDoubleScore augment)
Scoreaugment - value to be added to this Scorepublic SimpleDoubleScore subtract(SimpleDoubleScore subtrahend)
Scoresubtrahend - value to be subtracted from this Scorepublic SimpleDoubleScore multiply(double multiplicand)
ScoreMath.floor(double).
If the implementation has a scale/precision, then the unspecified scale/precision of the double multiplicand should have no impact on the returned scale/precision.
multiplicand - value to be multiplied by this Score.public SimpleDoubleScore divide(double divisor)
ScoreMath.floor(double).
If the implementation has a scale/precision, then the unspecified scale/precision of the double divisor should have no impact on the returned scale/precision.
divisor - value by which this Score is to be dividedpublic SimpleDoubleScore power(double exponent)
ScoreMath.floor(double).
If the implementation has a scale/precision, then the unspecified scale/precision of the double exponent should have no impact on the returned scale/precision.
exponent - value by which this Score is to be poweredpublic SimpleDoubleScore negate()
Scorepublic Number[] toLevelNumbers()
Score
When rounding is needed, each rounding should be floored (as defined by Math.floor(double).
The length of the returned array must be stable for a specific Score implementation.
For example: -0hard/-7soft returns new int{-0, -7}
ScoreDefinition.fromLevelNumbers(Number[])public int compareTo(SimpleDoubleScore other)
Copyright © 2006–2016 JBoss by Red Hat. All rights reserved.