Package bitchanger.calculations
Interface ChangeableNumber
-
- All Known Implementing Classes:
SimpleChangeableNumber
public interface ChangeableNumber
Interface that defines methods to convert numbers from any numeral system into another numeral system- Since:
- Bitchanger 0.1.0
- Version:
- 1.0.0
- Author:
- Tim Muehle
-
-
Field Summary
Fields Modifier and Type Field Description static String
NaN
static String
NEGATIVE_INFINITY
static String
POSITIVE_INFINITY
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default double
asDouble()
javafx.beans.property.IntegerProperty
baseProperty()
javafx.beans.property.ReadOnlyStringProperty
logicStringProperty()
void
reset()
Resets the wrapped value.void
set(double decValue)
void
setBin(String binValue)
Sets the value of thisChangeableNumber
to the value of a binary stringvoid
setDec(String decValue)
Sets the value of thisChangeableNumber
to the value of a decimal stringvoid
setHex(String hexValue)
Sets the value of thisChangeableNumber
to the value of a hexadecimal stringvoid
setIEEE(String ieee, IEEEStandard standard)
Sets the value of thisChangeableNumber
to a value of one of both IEEE standards (16 Bit or 32 Bit)void
setOct(String octValue)
Sets the value of thisChangeableNumber
to the value of an octal stringvoid
setValue(String value, int baseOfValue)
Sets the value of thisChangeableNumber
to a value of any numeral systemjavafx.beans.property.ReadOnlyStringProperty
stringProperty()
String
toBaseString(int base)
Returns the string representation of thisChangeableNumber
to any base.String
toBinString()
Returns the string representation of thisChangeableNumber
as a binary string.String
toDecString()
Returns the string representation of thisChangeableNumber
as a decimal string.String
toHexString()
Returns the string representation of thisChangeableNumber
as a hexadecimal string.String
toIEEEString(IEEEStandard standard)
Returns the String representation of thisChangeableNumber
as IEEE standard String.String
toOctString()
Returns the string representation of thisChangeableNumber
as an octal string.
-
-
-
Field Detail
-
NaN
static final String NaN
- See Also:
- Constant Field Values
-
POSITIVE_INFINITY
static final String POSITIVE_INFINITY
- See Also:
- Constant Field Values
-
NEGATIVE_INFINITY
static final String NEGATIVE_INFINITY
- See Also:
- Constant Field Values
-
-
Method Detail
-
asDouble
default double asDouble()
-
set
void set(double decValue) throws NullPointerException, NumberFormatException, IllegalArgumentException, NumberOverflowException
-
setHex
void setHex(String hexValue) throws NullPointerException, NumberFormatException, IllegalArgumentException
Sets the value of thisChangeableNumber
to the value of a hexadecimal string- Parameters:
hexValue
- New Value that is represented as a hexadecimal string by this class- Throws:
NullPointerException
- if the parameterhexValue
isnull
NumberFormatException
- if the parameterhexValue
is not a number of the hexadecimal systemIllegalArgumentException
- ifhexValue
is an empty string
-
setDec
void setDec(String decValue) throws NullPointerException, NumberFormatException, IllegalArgumentException
Sets the value of thisChangeableNumber
to the value of a decimal string- Parameters:
decValue
- New value that is represented as a decimal string by this class- Throws:
NullPointerException
- if the parameterdecValue
isnull
NumberFormatException
- if the parameterdecValue
is not a number of the decimal systemIllegalArgumentException
- ifdecValue
is an empty string
-
setOct
void setOct(String octValue) throws NullPointerException, NumberFormatException, IllegalArgumentException
Sets the value of thisChangeableNumber
to the value of an octal string- Parameters:
octValue
- New value that is represented as an octal string by this class- Throws:
NullPointerException
- if the parameteroctValue
isnull
NumberFormatException
- if the parameteroctValue
is not a number of the octal systemIllegalArgumentException
- ifoctValue
is an empty string
-
setBin
void setBin(String binValue) throws NullPointerException, NumberFormatException, IllegalArgumentException
Sets the value of thisChangeableNumber
to the value of a binary string- Parameters:
binValue
- New value that is represented as a binary string by this class- Throws:
NullPointerException
- if the parameterbinValue
isnull
NumberFormatException
- if the parameterbinValue
is not a number of the binary systemIllegalArgumentException
- ifbinValue
is an empty string
-
setValue
void setValue(String value, int baseOfValue) throws NullPointerException, NumberFormatException, IllegalArgumentException
Sets the value of thisChangeableNumber
to a value of any numeral system- Parameters:
value
- New value that is represented as string by this classbaseOfValue
- Base of the numeral system ofvalue
- Throws:
NullPointerException
- if the parametervalue
isnull
NumberFormatException
- if the parametervalue
is not a number of the binary systemIllegalArgumentException
- ifvalue
is an empty string or ifbaseOfValue
leaves the range of values [2, 36] - seeConvertingNumbers.isValueToBase(int base, String value)
-
setIEEE
void setIEEE(String ieee, IEEEStandard standard) throws NullPointerException, NumberFormatException, IllegalArgumentException, NumberOverflowException
Sets the value of thisChangeableNumber
to a value of one of both IEEE standards (16 Bit or 32 Bit)- Parameters:
ieee
- New Value that is represented as a String, by this classstandard
- Standard of the used IEEE standard ofieee
- Throws:
NullPointerException
- if the parameterieee
isnull
NumberFormatException
- if the parameterieee
is not a number of the binary system or has more characters than 16 respectively 32IllegalArgumentException
- ifieee
is an empty String orstandard
is something else than 16 or 32NumberOverflowException
- Since:
- Bitchanger 0.1.6
-
reset
void reset()
Resets the wrapped value. The previous value gets deleted! If a toString method is called after this method, an empty string will be returned.The wrapped value can be set again by using one of the set methods.
-
toHexString
String toHexString()
Returns the string representation of thisChangeableNumber
as a hexadecimal string.The string is not labeled as hexadecimal, so the prefix is not leading!
- Returns:
- hexadecimal string representation of this
ChangeableNumber
-
toDecString
String toDecString()
Returns the string representation of thisChangeableNumber
as a decimal string.- Returns:
- decimal string representation of this
ChangeableNumber
-
toOctString
String toOctString()
Returns the string representation of thisChangeableNumber
as an octal string.The string is not labeled as octal, so the prefix is not leading!
- Returns:
- octal string representation of this
ChangeableNumber
-
toBinString
String toBinString()
Returns the string representation of thisChangeableNumber
as a binary string.The string is not labeled as binary, so the prefix is not leading!
- Returns:
- binary string representation of this
ChangeableNumber
-
toBaseString
String toBaseString(int base) throws IllegalArgumentException
Returns the string representation of thisChangeableNumber
to any base.The String is not labeled by a prefix!
- Parameters:
base
- Base of the numeral system, in which thisChangeableNumber
is represented- Returns:
- String representation of this
ChangeableNumber
to the committed base - Throws:
IllegalArgumentException
- ifbase
leaves the range of values [2, 36] - seeConvertingNumbers.isValueToBase(int, String)
-
toIEEEString
String toIEEEString(IEEEStandard standard) throws ArithmeticException
Returns the String representation of thisChangeableNumber
as IEEE standard String.- Parameters:
standard
- IEEE standard that is used for converting- Returns:
- IEEE as String representation of this
ChangeableNumber
- Throws:
ArithmeticException
- if this number cannot be presented by the given ieee standard- Since:
- Bitchanger 0.1.6
-
stringProperty
javafx.beans.property.ReadOnlyStringProperty stringProperty()
- Returns:
- Since:
- Bitchanger 0.1.7
-
logicStringProperty
javafx.beans.property.ReadOnlyStringProperty logicStringProperty()
- Returns:
- Since:
- Bitchanger 0.1.7
-
baseProperty
javafx.beans.property.IntegerProperty baseProperty()
- Returns:
- Since:
- Bitchanger 0.1.7
-
-