Skip to content
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

used_bits implementation for signed_multiprecision #67

Closed
hbe72 opened this issue Oct 24, 2017 · 1 comment
Closed

used_bits implementation for signed_multiprecision #67

hbe72 opened this issue Oct 24, 2017 · 1 comment
Assignees
Labels

Comments

@hbe72
Copy link
Collaborator

hbe72 commented Oct 24, 2017

This works:
using q4_20 = cnl::fixed_point<unsigned_multiprecision<24>,-20>;
q4_20 a = 3.051757812500000e-05;
` std::cout << "a : " << a << " used_bits : " << used_bits(a) << " leading bits : " << leading_bits(a) << std::endl;'

Producing correctly:
a : 3.0517578125e-05 used_bits : 6 leading bits : 18

This fails:
using q4_20 = cnl::fixed_point<signed_multiprecision<24>,-20>;
q4_20 a = 3.051757812500000e-05;
` std::cout << "a : " << a << " used_bits : " << used_bits(a) << " leading bits : " << leading_bits(a) << std::endl;'

with:
a : 3.0517578125e-05 used_bits : unknown file: Failure
C++ exception with description "Division by zero." thrown in the test body.
Process finished with exit code 1

@johnmcfarlane johnmcfarlane self-assigned this Oct 24, 2017
johnmcfarlane added a commit that referenced this issue Nov 5, 2017
…ypes

- addresses [issue#67](#67)
- pass by `const&` to avoid costly copies of (potentially) large objects
- do not rely on `sizeof(I)*CHAR_BIT` to measure bit width
  - use `cnl::digits` instead
johnmcfarlane added a commit that referenced this issue Nov 6, 2017
…ypes

- addresses [issue#67](#67)
- pass by `const&` to avoid costly copies of (potentially) large objects
- do not rely on `sizeof(I)*CHAR_BIT` to measure bit width
  - use `cnl::digits` instead
@johnmcfarlane
Copy link
Owner

Fixed in #69. Sorry for the delay. Other things have gotten in the way of a lot of much-needed work in CNL recently.

troian pushed a commit to notifai/cnl that referenced this issue May 6, 2021
…ypes

- addresses [issue#67](johnmcfarlane#67)
- pass by `const&` to avoid costly copies of (potentially) large objects
- do not rely on `sizeof(I)*CHAR_BIT` to measure bit width
  - use `cnl::digits` instead
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants