[英]How to write pow to Unit Java (JScience)
我正在使用JScience API編寫單元,但無法使用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
我認為這是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
如果第一個字節數組與第二個字節數組具有相同的字節,則輸出正確,但是您的控制台無法顯示字符³
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.