I am using JScience API to write units, but I am not able use pow method. How to write pow for unit?
Unit<Length> centimeter = SI.CENTIMETER;
//Unit<Length> cm3 = centimeter.pow(3);eclipse suggests to add cast
Unit<Length> cm3 = (Unit<Length>) centimeter.pow(3);
System.out.println(cm3); // prints cm? instead of cm^3
I think it is a UTF-8 3-superscript?
See also here: http://www.fileformat.info/info/unicode/char/b3/index.htm
You can check it by analysing the bytes from cm3.toString()
byte[] bs = cm3.toString().getBytes("UTF-8");
for ( byte b : bs )
{
System.out.println( b );
}
My output (using 3 superscript) of the next string:
byte[] bs = "cm³".getBytes( "UTF-8" ); // byte[] bs = "cm\u00B3".getBytes( "UTF-8" );
for ( byte b : bs )
{
System.out.println( b );
}
99
109
-62
-77
If the first byte array has the same bytes as the second, the output is correct, but your console cannot display the character ³