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

add support for all basic golang number types #137

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

grische
Copy link
Collaborator

@grische grische commented Jul 25, 2024

This fixes a bug where an int64 was detected for a number larger than the largest int64 number.
The number 9993372000000000000 was detected as int64, despite the fact that it is outside of the limit 9223372036854775807 because 9993372030000000000 % 1 == 0, but well within float64 limits.

If the other data types are unwanted, let me know.

@grische grische mentioned this pull request Jul 25, 2024
@grische grische force-pushed the fix/float-detection-for-larger-numbers branch 2 times, most recently from cfd66e1 to 93ef0cf Compare July 25, 2024 18:38
this also fixes a bug where an int64 was detected for a number larger
than the largest int64 number
@grische grische force-pushed the fix/float-detection-for-larger-numbers branch from 93ef0cf to 342ae50 Compare July 25, 2024 21:05
Copy link
Owner

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting idea; I think it makes sense to use float when needed, but as for all int types other than int64, I don't think they are commonly used except when there are specific needs to use a certain number of bytes. i.e. I don't see int8 or int16 or int32 very often.

@grische
Copy link
Collaborator Author

grische commented Jul 25, 2024

@mholt I also think that other types but int might be actually harmful for many use cases. Imagine one is an ID and this ID is of int64 and just incremented. The example json might just contain the first few samples, i.e. turning into an int8 and then causing problems later on.

If you are OK with #141 I will hide this feature behind a flag (--small-ints maybe?) and leave the default to be int.

Note: the size of int is probably already int64, depending on the platform being used.

@grische
Copy link
Collaborator Author

grische commented Jul 26, 2024

I have prepared a commit for the new flag: a930048

Once we have decided on how to proceed with #144 , I can update this PR.

@grische grische marked this pull request as draft July 26, 2024 18:47
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

Successfully merging this pull request may close these issues.

2 participants