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

[Bug] - Casting Int to Float Throw InvalidCastException: Instance of JsonData doesn't hold a double #94

Open
levey-lee opened this issue Sep 22, 2018 · 0 comments

Comments

@levey-lee
Copy link

levey-lee commented Sep 22, 2018

This happens when casting an integer in an array to a float.

For example:
If we have an array of int like this: [0,1,2] where we use it as a vector3. In our code, Json will throw an exception if we cast it like (float)data[0].

My workaround:
I have to do an integer cast then float cast from system. It will work if you do (float)(int)data[0]. However, you need to make sure the type is int or long, otherwise you will lose float precise for other floating point data.

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