Commit Graph

406 Commits

Author SHA1 Message Date
Josh Stone e1361fe3e0 Fix copysign tests for 1.8.0 2022-04-29 18:37:16 -07:00
Josh Stone 2fe191843c Make sure test_copysignf uses Float 2022-04-29 18:37:16 -07:00
XAMPPRocky 1b04b78740 Update float.rs 2022-04-29 18:10:11 -07:00
XAMPPRocky fdd43fad3d Update float.rs 2022-04-29 18:10:11 -07:00
XAMPPRocky fac306842a Update float.rs 2022-04-29 18:10:11 -07:00
Erin Power 37575361a6 Add copysign 2022-04-29 18:10:11 -07:00
Josh Stone 05fd16d2a0 Forward euclid methods when possible 2022-04-29 17:53:50 -07:00
Josh Stone 039fb91251 tweak euclid tests 2022-04-29 17:22:07 -07:00
SparrowLii d68870321f take references as parameters 2022-04-29 17:22:07 -07:00
SparrowLii 7ece7edabf fixes codes structure etc. 2022-04-29 17:22:07 -07:00
SparrowLii a0a6154a75 Fixes epsilon 2022-04-29 17:22:07 -07:00
SparrowLii e4b037c2c0 fixes MIN 2022-04-29 17:22:07 -07:00
SparrowLii 59a72a8fb9 Fixes methods 2022-04-29 17:22:07 -07:00
SparrowLii f09717c82b fixes method impl 2022-04-29 17:22:07 -07:00
SparrowLii d4191d236c Fixes use core::float 2022-04-29 17:22:07 -07:00
SparrowLii dde1bdda60 fixes example 2022-04-29 17:22:07 -07:00
SparrowLii 4533ad7bb0 fixes ::Float 2022-04-29 17:22:07 -07:00
SparrowLii 6f778fafdf fixes float::Float and fmt 2022-04-29 17:22:07 -07:00
SparrowLii b3ba355daa Add support for euclidean division and modulation 2022-04-29 17:22:07 -07:00
Sergei Shilovsky da62ee51e6 Skip check_numassignref_ops test for old rustc 2022-04-29 16:58:43 -07:00
Sergei Shilovsky 527da0fa21 Highlight difference in traits' abstraction level
Short descriptions for NumOps sort of blended in with NumRef and RefNum.
This suggests to clarify the difference a little bit more.
2022-04-29 16:57:11 -07:00
Sergei Shilovsky ad307574de add test: check_numassignref_ops 2022-04-29 16:57:11 -07:00
Sergei Shilovsky 7220b0bcd3 impl Num Wrapping<T> can rely on NumOps instead 2022-04-29 16:57:11 -07:00
alion02 78aae4c700 Fix cfg typo 2022-01-21 02:23:32 +01:00
Alex S c24991f3f3 Reimplement is_sign_negative as a bitcast, libm not necessary. 2021-07-01 00:39:26 +03:00
Alex S 622263ab9f Implement is_sign_* and signum methods in terms of libm. 2021-06-24 19:40:54 +03:00
Josh Stone 5bf2599fef Merge branch 'master' into reverse-bits 2021-06-15 17:30:17 -07:00
bors[bot] 89cf792ed1 Merge #214
214: Ignore case for float parsing of text special values r=cuviper a=tspiteri

This copies some of the standard library fixes of <https://github.com/rust-lang/rust/pull/78618>.

Co-authored-by: Trevor Spiteri <tspiteri@ieee.org>
2021-06-16 00:18:05 +00:00
Trevor Spiteri 4154fb5af9 Ignore case for float parsing of text special values
This copies some of the standard library fixes of
<https://github.com/rust-lang/rust/pull/78618>.
2021-04-15 20:15:46 +02:00
Xiretza 9b9d0ef5d7 PrimInt: add unit tests for reverse_bits 2021-04-13 22:30:09 +02:00
ltdk d989634fda Add leading_ones and trailing_ones to PrimInt 2021-04-09 21:43:48 -04:00
ltdk c235ad63f0 Add LowerBounded/UpperBounded traits 2021-03-22 15:23:51 -04:00
Xiretza 54a371e00c PrimInt: add fallback for reverse_bits on rustc<1.37 2021-03-02 14:41:28 +01:00
bors[bot] 534a8170b6 Merge #196
196: Use libm in Float::{min,max} and in FloatCore r=cuviper a=cuviper



Co-authored-by: Josh Stone <cuviper@gmail.com>
2021-03-02 00:01:34 +00:00
Xiretza 235f67cd6f PrimInt: add reverse_bits() method 2021-02-12 14:27:18 +01:00
Trevor Spiteri 3b7fd3af79 match standard library float parsing of "-NaN" 2021-02-05 19:18:57 +01:00
Trevor Spiteri 00b5a1d41e use standard library for float from_str_radix with radix 10 2021-02-05 19:03:58 +01:00
Josh Stone c54841995a Use libm in Float::{min,max} and in FloatCore 2020-11-13 18:26:06 -08:00
Josh Stone ba57faeacd Update the names for overflowing results 2020-10-29 15:19:35 -07:00
Josh Stone e4723c3e39 Document relaxed requirements for Num::from_str_radix 2020-10-29 15:02:46 -07:00
bors[bot] 9f672817d3 Merge #185 #186 #190
185: Trust the "i128" feature r=cuviper a=cuviper

If the "i128" feature is explicity requested, don't bother probing for
it. It will still cause a build error if that was set improperly.

186: Allow large f64-to-f32 to saturate to infinity r=cuviper a=cuviper

The implementation of `<f64 as ToPrimitive>::to_f32` was written at a
time when float-to-float overflow was though to be undefined behavior,
per rust-lang/rust#15536, but this was later determined to be fine.
Casting a large `f64` to `f32` just results in an infinity with the
matching sign. The sign gives more information than if `to_f32` just
returns `None`, so now we let these infinities through as a result.

See also rust-num/num-bigint#163 and rust-num/num-rational#83.

190: Normalize the comment style r=cuviper a=cuviper



Co-authored-by: Josh Stone <cuviper@gmail.com>
2020-10-29 20:52:48 +00:00
bors[bot] e9683c775d Merge #180
180: Add Overflowing trait r=cuviper a=KaczuH

Closes issue #168

I've been inspired by `saturated.rs`

Co-authored-by: Kamil Niski <kamil.niski@gmail.com>
2020-10-29 20:46:52 +00:00
Kamil Niski b2a6df9869 Correct docs for overflowing docs 2020-10-24 14:36:38 +02:00
Josh Stone 3aeede4e29 Normalize the comment style 2020-10-06 14:46:22 -07:00
Josh Stone c2997d6c3d Allow large f64-to-f32 to saturate to infinity
The implementation of `<f64 as ToPrimitive>::to_f32` was written at a
time when float-to-float overflow was though to be undefined behavior,
per rust-lang/rust#15536, but this was later determined to be fine.
Casting a large `f64` to `f32` just results in an infinity with the
matching sign. The sign gives more information than if `to_f32` just
returns `None`, so now we let these infinities through as a result.

See also rust-num/num-bigint#163 and rust-num/num-rational#83.
2020-08-27 17:17:32 -07:00
Martin Taibr f3b54e0c95 remove example which was never UB from AsPrimitive docs 2020-08-21 04:59:29 +02:00
Martin Taibr 90a8de74ee update AsPrimitive Safety docs for rust 1.45 2020-07-30 23:42:53 +02:00
Kamil Niski 7d66a73e7f Remove std dep from integer MAX, MIN 2020-07-17 08:33:54 +02:00
Kamil Niski 98a050fcc0 Add Overflowing trait
Closes issue #168
2020-07-17 08:18:13 +02:00
Eduardo Pinho 2997cd8cda #175 document cast traits about precision loss
- Document on `ToPrimitive`, `FromPrimitive` and `NumCast` that
  scalars can be represented by the target type
  when they are within the range admitted by the target type,
  and so truncation/precision loss may happen
2020-07-05 23:07:07 +01:00