Coder Social home page Coder Social logo

hexf's People

Contributors

ajtribick avatar lifthrasiir avatar littledivy avatar pchickey avatar sanxiyn avatar sunfishcode avatar youknowone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hexf's Issues

Hex literals with large exponents are incorrectly rejected

Hex literals with a mantissa that would be larger than 64 bits before applying the exponent are incorrectly rejected. For example,

parse_hex64("0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000p-1474", false)

returns an error.

A better API for handling input that has already been parsed

The Naga crate uses hexf_parse to handle hex float literals in WGSL. Our front end has already verified that the text conforms to WGSL's grammar for hex float literals, but since that grammar has subtle differences from this library's grammar, we have to use format! to reassemble the pieces into what parse_hexf64 expects.

It'd be nicer if this library could accept a struct like this:

struct HexFloatParts<'a> {
    negative: bool,
    integer: Option<&'a str>,
    fraction: Option<&'a str>,
    exponent: Option<&a str>,
}

please consider relicensing the hexf / hexf-parse crates

The CC0-1.0 license is no longer considered to be a suitable license for code by some lawyers in the open-source licensing space (it is still considered a "good" license for content). For example, code licensed under the CC0-1.0 license is no longer allowed to be packaged for Fedora Linux since July 2022: https://lists.fedoraproject.org/archives/list/[email protected]/message/RRYM3CLYJYW64VSQIXY6IF3TCDZGS6LM/

For context - I am currently working on packaging ruff (a very fast Python linter) for Fedora Linux, and one of its dependencies is the hexf-parse crate. Currently, providing a package for ruff would be blocked because hexf-parse cannot be packaged and / or distributed by us.

Alternatives to CC0-1.0 that are still "good" licenses for code might be Unlicense, MIT-0, or 0BSD. Note that of these three, only the Unlicense appears to be considered a FOSS license by both the FSF and the OSI, whereas MIT-0 and 0BSD are only OSI-approved (c.f. https://spdx.org/licenses/).

Consider using a union instead

According to this comment, we can use a union to construct the float value more directly.

It might be worth going through that route to avoid depending on the float parsing machinery.

thread 'main' panicked at 'attempt to shift left with overflow'

hexf panics on the following code:

hexf_parse::parse_hexf64("0x.000000000000000000102");

The backtrace points to this line: https://github.com/lifthrasiir/hexf/blob/master/parse/src/lib.rs#L138

It looks like you try to catch the error the line before, I'm not sure why it still keeps going: https://github.com/lifthrasiir/hexf/blob/master/parse/src/lib.rs#L135

Backtrace
thread 'main' panicked at 'attempt to shift left with overflow', /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/hexf-parse-0.1.0/src/lib.rs:138:19
... panic code ...
  15: hexf_parse::parse
             at /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/hexf-parse-0.1.0/src/lib.rs:138
  16: hexf_parse::parse_hexf64
             at /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/hexf-parse-0.1.0/src/lib.rs:394
... my code ...

parsing fails for input "0x0.1E"

fn main() {
    assert_eq!(
        0.1171875,
        hexf_parse::parse_hexf64("0x0.1E", false).expect("failed to parse")
    );
}

output:

thread 'main' panicked at 'failed to parse: ParseHexfError { kind: Invalid }', src/main.rs:4:51

I have no idea how floats work, so apologies if this is a mistake.

Works with Rust 1.43

I just checked if hexf 0.2.1 can compile with Rust 1.43 and it seems to work just fine. Was there any particular reason for the MSRV of 1.45? If possible I'd appreciate it if the MSRV could be lowered to 1.43 (at least for versions 0.2.x), as this would allow me to use hexf-parse for gfx-rs/naga#1184.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.