rust-num / num-traits

Numeric traits for generic mathematics in Rust
Apache License 2.0
731 stars 135 forks source link

convert between integer and byte array #103

Closed flier closed 1 year ago

flier commented 5 years ago

After Rust 1.32, the function to_<endian>_bytes and from_<endian>_bytes has stabilizations.

flier commented 5 years ago

Tests seem crashed at src/int.rs - int::PrimInt::unsigned_shr (line 173)

---- src/int.rs - int::PrimInt::unsigned_shr (line 173) stdout ----
error: literal out of range for i64
 --> src/int.rs:176:9
  |
6 | let n = 0xFEDCBA9876543210i64;
  |         ^^^^^^^^^^^^^^^^^^^^^ help: consider using `u64` instead: `0xFEDCBA9876543210u64`
  |
  = note: #[deny(overflowing_literals)] on by default
  = note: the literal `0xFEDCBA9876543210i64` (decimal `18364758544493064720`) does not fit into an `i64` and will become `-81985529216486896i64`
thread 'src/int.rs - int::PrimInt::unsigned_shr (line 173)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:351:13
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
erikbrinkman commented 3 years ago

The PR seems to have gone fallow, but if you come back to it, it'd be great to extend this to the float types as they also got these methods in 1.40.

flier commented 3 years ago

Hi @erikbrinkman and @cuviper

The PR has be updated

cuviper commented 1 year ago

Sorry, I pushed to this branch on accident, but the revived development is in #224.