Skip to content

Optimize to_string() for power of two bases #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion arbi/src/base.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2024 Owain Davies
Copyright 2024-2025 Owain Davies
SPDX-License-Identifier: Apache-2.0 OR MIT
*/

Expand Down Expand Up @@ -159,6 +159,7 @@ impl Base {
///
/// let b36 = Base::new(36).unwrap();
/// ```
#[inline]
pub fn new(value: u8) -> Result<Self, BaseError> {
value.try_into()
}
Expand All @@ -172,6 +173,7 @@ impl Base {
/// let b10 = Base::new(10).unwrap();
/// assert_eq!(b10.value(), 10);
/// ```
#[inline]
pub fn value(self) -> u8 {
self.0
}
Expand Down
1 change: 1 addition & 0 deletions arbi/src/bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ mod tests {
#[cfg(test)]
mod random {
use super::*;
use alloc::vec;

macro_rules! test_bit_ops_for_type {
($rng:expr, $die:expr) => {
Expand Down
1 change: 1 addition & 0 deletions arbi/src/builtin_int_methods/trailing_zeros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ mod tests {
use crate::util::test::{get_seedable_rng, get_uniform_die, Distribution};
use crate::Arbi;
use crate::{BitCount, DDigit, Digit};
use alloc::vec;

macro_rules! assert_trailing_zeros {
($value:expr) => {
Expand Down
157 changes: 0 additions & 157 deletions arbi/src/floor.rs

This file was deleted.

3 changes: 0 additions & 3 deletions arbi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ mod division;
pub mod docs;
mod exponentiation;
mod fits;
mod floor;
mod fmt;
mod from_double;
mod from_integral;
Expand Down Expand Up @@ -96,8 +95,6 @@ type QDigit = u128;
#[allow(dead_code)]
type SQDigit = i128;

const DBL_MAX_INT: u64 = 0x20000000000000; // 2 ** 53

/// Arbitrary Precision Integer type.
///
/// # Internal Representation
Expand Down
1 change: 1 addition & 0 deletions arbi/src/ops/bit/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ mod tests {
use super::BitwiseOp;
use crate::util::test::{get_seedable_rng, get_uniform_die, Distribution};
use crate::{Arbi, DDigit, Digit};
use alloc::{format, vec};
use core::ops::RangeInclusive;

struct BitwiseTestCase {
Expand Down
1 change: 1 addition & 0 deletions arbi/src/right_shift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ mod test_arithmetic_rshift {
use crate::{
Arbi, Assign, BitCount, DDigit, Digit, SDDigit, SDigit, SQDigit,
};
use alloc::vec;

#[test]
fn test_mark_a() {
Expand Down
4 changes: 2 additions & 2 deletions arbi/src/to_double.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2024 Owain Davies
Copyright 2024-2025 Owain Davies
SPDX-License-Identifier: Apache-2.0 OR MIT
*/

Expand Down Expand Up @@ -61,7 +61,7 @@ mod tests {
use super::*;
use crate::util::test::float::*;
use crate::util::test::{get_seedable_rng, get_uniform_die, Distribution};
use crate::{DDigit, QDigit, SDDigit, SQDigit, DBL_MAX_INT};
use crate::{DDigit, QDigit, SDDigit, SQDigit};

#[test]
fn smoke() {
Expand Down
Loading