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

Enforce a strict number type across the code. #374

Open
maschad opened this issue Jan 29, 2025 · 3 comments
Open

Enforce a strict number type across the code. #374

maschad opened this issue Jan 29, 2025 · 3 comments

Comments

@maschad
Copy link
Member

maschad commented Jan 29, 2025

Throughout the repo we use u64 types as well as i64 types, I suppose the latter is due to postgres using i64 to represent their BIGINT but this of course can lead to loss of precision, particularly when converting from floating point types as well. So we need a consolidated approach to handling these types.

My recommendation would be to standardize signed integer types across the entire repo.

@jorgeantonio21
Copy link
Contributor

I might be wrong, but I don't recall any cast from float points to i64 directly. Any concrete example ?

@maschad
Copy link
Member Author

maschad commented Jan 29, 2025

@jorgeantonio21 you are correct, forgive my poor wording, I should have said "converting to floating point types"

But we actually do cast from i64 to f64 such as here for instance, and casting i64 to f64 causes a loss of precision (i64 is 64 bits wide, but f64's mantissa is only 52 bits wide)

@jorgeantonio21
Copy link
Contributor

I see, that said I believe these cases are pretty safe to cast, but we should definitely flag them all

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

No branches or pull requests

2 participants