Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

浮点型与整型转换问题修复 #326

Closed
DingliZhang opened this issue Jan 12, 2022 · 0 comments
Closed

浮点型与整型转换问题修复 #326

DingliZhang opened this issue Jan 12, 2022 · 0 comments

Comments

@DingliZhang
Copy link

DingliZhang commented Jan 12, 2022

#39 (comment) 中修复了几个RV64 only的浮点数指令导致的非法指令问题,但是只是简单的将RV64更改为相应的RV32的指令,会导致数据丢失,从而得到错误的结果。

测试用例:

public class TestConvertLFD {
    public static void main(String[] args) {
        long a = 0xFFFFFFF0FFFFFF00L;
        float b = -64424509696F;
        double c = -64424509696D;

        System.out.println("test l2f in: "+a+" out: "+ (float)a );
        System.out.println("test l2d in: "+a+" out: "+ (double)a);
        System.out.println("test f2l in: "+b+" out: "+ (long)b);
        System.out.println("test d2l in: "+c+" out: "+ (long)c);
    }
}

可以参考 #306 ,使用 SharedRuntime::xx 来进行运算。

修复结果对比

修复前结果(jdk-10/bin/java 的输出为x86版本jdk的正确结果):

149082355-be560d13-07f1-4fd6-a395-a598715b03a5

修复后结果(jdk-10/bin/java 的输出为x86版本jdk的正确结果):

image

已提交PR #325

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant