Closed averbraeck closed 1 year ago
The code:
SIScalar s1 = Torque.of(1.33, "N.m").divide(Energy.valueOf("2.1 J"));
System.out.println("|" + s1 + "|");
now displays:
|0.63333333 |
A demo called DimensionlessExample
has been added to the djunits-demo project to show the parsing and printing of Dimensionless
and FloatDimensionless
scalars, as well as SIScalar
and FloatSIScalar
where the SI dimensions are 1. Examples for Vector
, FloatVector
, SIVector
and FloatSIVector
are also included.
A helper static constant for the SIUnit
class called DIMLESS
is added. It is the DIMLESS
is defined as the SIUnit
with all dimensions equal to zero:
SIUnit DIMLESS = SIUnit.of(new SIDimensions(0, 0, 0, 0, 0, 0, 0, 0, 0));
All 283 unit tests pass again after the changes of the SIDimensions
and SIUnit
to accept and print an empty string for a dimensionless quantity.
The following changes have been made:
DimensionlessUnit
has an empty string as the default unit id and unit name.Dimensionless
can parse an empty string as the unit in the of(...)
and valueOf(...)
methodsFloatDimensionless
can parse an empty string as the unit in the of(...)
and valueOf(...)
methodsSIDimensions
accepts an empty string as the unit in the of(...)
and parse(...)
methodsSIDimensions
has a static constant called DIMLESS
to indicate a dimensionless SI tupleSIUnit
has a static constant called DIMLESS
to indicate a dimensionless SI unitSIScalar
accepts an empty string as the unit in the of(...)
and valueOf(...)
methodsFloatSIScalar
accepts an empty string as the unit in the of(...)
and valueOf(...)
methodsSIVector
can parse an empty string as the unit in the three of(...)
methodsFloatSIVector
can parse an empty string as the unit in the three of(...)
methodsSIMatrix
can parse an empty string as the unit in the of(...)
methodFloatSIMatrix
can parse an empty string as the unit in the of(...)
methodDimensionlessExample
has been added to the djunits-demo projectThis covers all known issues with dimensionless SI values to not print or use '1' anymore as the unit, but leave it blank in the exact way that Dimensionless
now prints it unit after Issue #12 was completed.
Currently, a dimensionless
SIScalar
prints a unit of '1'. Now that theDimensionless
prints a blank unit, theSIScalar
has to be changed as well to be consistent. As an example, the following code:prints: