java - 为什么这段代码不能在Java中运行?

标签 java android c pcm

Possible Duplicate:
unsigned short in java
Conversion of Audio Format in JAVA

我有一个将ulaw音乐转换为pcm格式的代码

代码是用C编写的,但现在,我需要它在java中运行

代码是这样的

short ALG_ulawDecode(unsigned short input)
{
unsigned short isNegative;

short nOut;

isNegative = ((input & 0x80) == 0);
if (isNegative)
    nOut = 127 - input;
else
    nOut = 255 - input;
if (nOut < 2)
    nOut *= 2;
else if (nOut < 16)
    nOut = ((nOut - 1) << 1) + 1 + 1;
else if (nOut < 32)
    nOut = ((nOut - 16) << 2) + 2 + 31;
else if (nOut < 48)
    nOut = ((nOut - 32) << 3) + 4 + 95;
else if (nOut < 64)
    nOut = ((nOut - 48) << 4) + 8 + 223;
else if (nOut < 80)
    nOut = ((nOut - 64) << 5) + 16 + 479;
else if (nOut < 96)
    nOut = ((nOut - 80) << 6) + 32 + 991;
else if (nOut < 112)
    nOut = ((nOut - 96) << 7) + 64 + 2015;
else
    nOut = ((nOut - 112) << 8) + 128 + 4063;
if (isNegative)
    nOut = -nOut;
nOut <<= 2;
return nOut;
}

由于 Java 不支持『unsigned Short』,所以无法运行

有人有什么建议吗?

感谢您的帮助!

最佳答案

任何人能给您的最好建议就是去阅读 Java 简介教程或书籍。

正如错误所述,unsigned short 不是 Java 中的原语。

关于java - 为什么这段代码不能在Java中运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14391524/

相关文章:

android - 如何在默认浏览器中为 Android 中的 onCreateWindow 打开请求?

php - Android AsyncTask 无法从 php-mysql 中检索 JSON 字符串

c - 在 Wininet 中使用 SSL

c - UBSAN 报告 : -875 << 7 as undefined behaviour

java - 奇怪的并发代码行为

java - Java 中的拖放 - 绘制的不仅仅是边框

java - 在java中使用正则表达式围绕空格/标点符号分割字符串时出现问题

日期添加计算中的Java "Integer number too large"

java - TableLayout 内的 ScrollView

使用函数和字符数组计算字符串长度的C程序