Comments (2)
This causes stack overflow. Probably this is also due to incorrect comparison of negative numbers. Andrey was writing & testing his functions with old buggy Stepan's comparisons. Probably we need to write ADD, SUB, MUL, DIV
from scratch 🍭 This is not that hard actually. We brainstormed this with Stepa this evening.
Moreover, we will write our own functions & rewrite completely unreadable Andrey's code.
START_TEST(int64_t_negatives) {
int64_t long_a = get_random_ll();
int64_t long_b = get_random_ll();
if (rand() % 2)
long_a *= -1;
if (rand() % 2)
long_b *= -1;
int64_t a = long_a;
int64_t b = long_b;
int64_t sum = a + b;
s21_decimal res128 = {0};
for (long long int i = 0, k = 0; i < 2; i++)
for (long long int j = 0; j < 32; j++, k++)
if (IS_SET(sum, k))
ADD_BIT(res128.bits[i], j);
s21_decimal dec_a = ll_to_decimal(long_a);
s21_decimal dec_b = ll_to_decimal(long_b);
s21_decimal dec_sum = {0};
s21_add(dec_a, dec_b, &dec_sum);
/* print_bits_r(dec_sum); */
ck_assert_int_eq(s21_is_equal(res128, dec_sum), TRUE);
}
Suite *suite_s21_add(void) {
Suite *s = suite_create(PRETTY_PRINT("s21_add"));
TCase *tc = tcase_create("s21_add_tc");
/* tcase_add_loop_test(tc, add_test1, 0, 1); */
tcase_add_loop_test(tc, gcc_128_bits, 0, 10000);
tcase_add_loop_test(tc, int64_t_negatives, 0, 10000);
suite_add_tcase(s, tc);
return s;
}
from s21_bigint.
It turns out there were two bugs with s21_sub. Now everything works fine. #57 closes this issue.
from s21_bigint.
Related Issues (16)
- [Feature Request] API for converting GMP large number to S21_DECIMAL HOT 5
- [Discussion] Integer overflow HOT 2
- [Build bug] Current release of the project fails to build both on MacOS & Alpine
- [QA] Add edge cases for division HOT 2
- [Bug] Truncate is lacking precision HOT 2
- s21_sub seems to have bugs HOT 2
- [Feat Request] Implement exponent handling in float div HOT 1
- Round & Decimal to float
- [CRITICAL BUG] s21_div goes into an infinite loop HOT 10
- [CRITICAL BUG] s21_add return code 1 (infinity sometimes) HOT 1
- our bank rounding is broken (5 is special case we need to check even/odd next number)
- I'm pretty sure these values are wrong. Double check this
- I'm pretty sure these values are wrong. Double check this HOT 2
- mod by 1
- Remove all gmp garbage
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from s21_bigint.