Skip to content

Commit

Permalink
Follow good practices (#162)
Browse files Browse the repository at this point in the history
<!--- Please provide a general summary of your changes in the title
above -->

## Pull Request type

<!-- Please try to limit your pull request to one type; submit multiple
pull requests if needed. -->

Please check the type of change your PR introduces:

- [ ] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes, no API changes)
- [ ] Build-related changes
- [ ] Documentation content changes
- [ ] Other (please describe):

## What is the current behavior?

<!-- Please describe the current behavior that you are modifying, or
link to a relevant issue. -->

Issue Number: N/A

## What is the new behavior?

<!-- Please describe the behavior or changes that are being added by
this PR. -->

-
-
-

## Does this introduce a breaking change?

- [ ] Yes
- [ ] No

<!-- If this does introduce a breaking change, please describe the
impact and migration path for existing applications below. -->

## Other information

<!-- Any other information that is important to this PR, such as
screenshots of how the component looks before and after the change. -->
  • Loading branch information
0xLucqs authored Aug 12, 2023
1 parent c2298ba commit b519245
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/math/src/karatsuba.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ fn multiply(x: u128, y: u128) -> u128 {
}

let max_digit_counts = max(count_digits_of_base(x, 10), count_digits_of_base(y, 10));
let middle_idx = _div_half_ceil(max_digit_counts);
let (x1, x0) = _split_number(x, middle_idx);
let (y1, y0) = _split_number(y, middle_idx);
let middle_idx = div_half_ceil(max_digit_counts);
let (x1, x0) = split_number(x, middle_idx);
let (y1, y0) = split_number(y, middle_idx);

let z0 = multiply(x0, y0);
let z1 = multiply(x1, y1);
Expand All @@ -33,7 +33,7 @@ fn multiply(x: u128, y: u128) -> u128 {
/// * `num` - The current value to be divided.
/// # Returns
/// * `u128` - Half (rounded up) of num.
fn _div_half_ceil(num: u128) -> u128 {
fn div_half_ceil(num: u128) -> u128 {
if num % 2 != 0 {
(num + 1) % 2
} else {
Expand All @@ -47,7 +47,7 @@ fn _div_half_ceil(num: u128) -> u128 {
/// * `split_idx` - Index at which the number will be split
/// # Returns
/// * `(u128, u128)` -tuple representing the split number.
fn _split_number(num: u128, split_idx: u128) -> (u128, u128) {
fn split_number(num: u128, split_idx: u128) -> (u128, u128) {
let divisor = pow(10, split_idx);
(num / divisor, num % divisor)
}
2 changes: 1 addition & 1 deletion src/math/src/tests/sha512_test.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use array::{ArrayTrait};
use array::ArrayTrait;
use alexandria_math::sha512::{WordOperations, sha512, Word64, Word64WordOperations};

fn get_lorem_ipsum() -> Array<u8> {
Expand Down

0 comments on commit b519245

Please sign in to comment.