我使用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发布于 2014-02-04 12:02:39
我认为这是一个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如果第一个字节数组具有与第二个字节相同的字节,则输出是正确的,但是控制台无法显示字符³。
https://stackoverflow.com/questions/21551800
复制相似问题