19 Commits

Author SHA1 Message Date
Urgau
00444bab26 Round negative signed integer towards zero in iN::midpoint
Instead of towards negative infinity as is currently the case.

This done so that the obvious expectations of
`midpoint(a, b) == midpoint(b, a)` and
`midpoint(-a, -b) == -midpoint(a, b)` are true, which makes the even
more obvious implementation `(a + b) / 2` true.

https://github.com/rust-lang/rust/issues/110840#issuecomment-2336753931
2024-10-26 18:46:41 +02:00
Ralf Jung
854e3c43e0 library: consistently use American spelling for 'behavior' 2024-10-25 12:02:47 +02:00
ltdk
362879d8c1 Run most core::num tests in const context too 2024-10-14 16:37:57 -04:00
Kappa322
467dbcba60 Improve documentation for <integer>::from_str_radix
Two improvements to the documentation:
- Document `-` as a valid character for signed integer destinations
- Make the documentation even more clear that extra whitespace and non-digit characters is invalid. Many other
  languages, e.g. c++, are very permissive in string to integer routines and simply try to consume as much as they can,
  ignoring the rest. This is trying to make the transition for developers who are used to the conversion semantics in
  these languages a bit easier.
2024-08-31 14:23:08 +02:00
Chai T. Rex
0cac915211 Improve isqrt tests and add benchmarks
* Choose test inputs more thoroughly and systematically.
* Check that `isqrt` and `checked_isqrt` have equivalent results for
  signed types, either equivalent numerically or equivalent as a panic
  and a `None`.
* Check that `isqrt` has numerically-equivalent results for unsigned
  types and their `NonZero` counterparts.
* Reuse `ilog10` benchmarks, plus benchmarks that use a uniform
  distribution.
2024-08-28 23:06:54 -04:00
Ben Kimock
4f3ef2ac90 Remove cfg(test) from library/core 2024-08-25 20:04:26 -04:00
Federico Stra
25648de28f isqrt: disable long running tests in Miri 2023-09-28 17:43:01 +02:00
Federico Stra
d49da0fe54 isqrt: add more tests 2023-09-26 16:05:51 +02:00
Federico Stra
1b34f1c6b2 isqrt: add tests 2023-09-22 16:11:26 +02:00
Loïc BRANSTETT
1a72d7c7c4 Implement midpoint for all signed and unsigned integers 2023-04-26 10:18:53 +02:00
Stovent
1266099742 Implement carrying_add and borrowing_sub on signed numbers 2022-05-30 18:32:27 -04:00
Jacob Pratt
dde590d180
Update int_roundings methods from feedback 2022-05-04 23:20:29 -04:00
Jacob Pratt
41f70f3491
Revert "Temporarily rename int_roundings functions to avoid conflicts"
This reverts commit 3ece63b64e192146fcdd1724e25856a93d7626aa.
2021-11-22 15:49:04 -05:00
Josh Triplett
3ece63b64e Temporarily rename int_roundings functions to avoid conflicts
These functions are unstable, but because they're inherent they still
introduce conflicts with stable trait functions in crates. Temporarily
rename them to fix these conflicts, until we can resolve those conflicts
in a better way.
2021-09-22 13:56:01 -07:00
Jacob Pratt
727a4fc7e3
Implement #88581 2021-09-02 01:53:54 -04:00
Christiaan Dirkx
6554086526 Add u128 and i128 integer tests 2020-11-14 20:27:08 +01:00
est31
a0fc455d30 Replace absolute paths with relative ones
Modern compilers allow reaching external crates
like std or core via relative paths in modules
outside of lib.rs and main.rs.
2020-10-13 14:16:45 +02:00
Mara Bos
1e2dba1e7c Use T::BITS instead of size_of::<T> * 8. 2020-09-19 06:54:42 +02:00
mark
2c31b45ae8 mv std libs to library/ 2020-07-27 19:51:13 -05:00