Skip to content

How to know the parsed digits is an integer? #14

@J-F-Liu

Description

@J-F-Liu

i.e. there is no '.' or 'e' in the literal.

Activity

aldanor

aldanor commented on Jan 31, 2021

@aldanor
Owner

Why, what's the use case? You don't, this information is not exported by the parser as it's not very useful.

lemire

lemire commented on Jan 31, 2021

@lemire
Contributor

If you write, say, a CSV or JSON parser, you may want to be able to know about the data type. E.g., in some systems "1.0" and "1" are to be treated differently. It is a niche use case, one where you need to determine the type dynamically, but it is not unreasonnable. Note that you would like the integer value (if it is an integer value) to be returned as an integer type so that you parse integers that would not fit in a floating-point type.

aldanor

aldanor commented on Feb 4, 2021

@aldanor
Owner

Closing this for now as it's outside of this crate's functionality.

(As a workaround for your use case - you could always check if there's a ., e or E in the source byte string, it should be very fast compared to the time spent actually parsing the float)

lemire

lemire commented on Feb 4, 2021

@lemire
Contributor

It seems likely that one could build a derived crate which implements this functionality.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @lemire@J-F-Liu@aldanor

        Issue actions

          How to know the parsed digits is an integer? · Issue #14 · aldanor/fast-float-rust