Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

v1.2.40 反序列化float field,当field精度超过float的精度范围,结果出现负数 #1723

@KaneWu0

Description

@KaneWu0
// Bean 对象
 public class User {
    private float age;
    public float getAge() {
        return age;
    }
    public void setAge(float age) {
        this.age = age;
    }
    @Override
    public String toString() {
        return "User{" +
                "age=" + age +
                '}';
    }
}
// 反序列化代码
User user = JSON.parseObject("{\"age\":\"0.9390308260917664\"}", User.class);
 System.out.println(user);

结果:
期望结果是:User{age=0.9390308}
实际结果是:User{age=-1.1075817}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions