0

我正在使用JScience API编写单元,但我无法使用 pow 方法。如何为单位写 pow?

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
4

1 回答 1

0

我认为它是 UTF-8 3 上标?

另请参阅:http ://www.fileformat.info/info/unicode/char/b3/index.htm

您可以通过分析来自的字节来检查它cm3.toString()

byte[] bs = cm3.toString().getBytes("UTF-8");
for ( byte b : bs )
{
    System.out.println( b );
}

我的下一个字符串的输出(使用 3 个上标):

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

如果第一个字节数组与第二个字节数组具有相同的字节,则输出正确,但您的控制台无法显示该字符³

于 2014-02-04T12:02:39.140 回答