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

feat: add PowToIntPart #28

Merged
merged 4 commits into from
Nov 19, 2024
Merged

feat: add PowToIntPart #28

merged 4 commits into from
Nov 19, 2024

Conversation

quagmt
Copy link
Owner

@quagmt quagmt commented Nov 18, 2024

Description

  • Add (d Decimal) PowToIntPart(e Decimal) which raises d to the power of integer part of e. This is useful when the exponent is stored in Decimal.

  • Adding this method instead of IntPart() (int32,error) to use with PowInt32 to avoid making the code unnecessarily complicated when we just need to raise a number to the power of its integer part (like the example below)

       intPart, err := a.IntPart()
       if err != nil {
          // handle error
       }
    
       d, err := c.PowInt32(intPart)
       if err != nil {
         // handle error
       }
  • Also add Int64() (int64,error) to return integer part if it fits int64

Copy link

codecov bot commented Nov 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.13%. Comparing base (f6d2877) to head (38e4c17).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #28      +/-   ##
==========================================
+ Coverage   95.94%   96.13%   +0.19%     
==========================================
  Files           5        5              
  Lines        1849     1863      +14     
==========================================
+ Hits         1774     1791      +17     
+ Misses         50       48       -2     
+ Partials       25       24       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

decimal.go Outdated Show resolved Hide resolved
decimal.go Outdated Show resolved Hide resolved
decimal.go Outdated Show resolved Hide resolved
decimal.go Outdated Show resolved Hide resolved
decimal.go Outdated Show resolved Hide resolved
u256.go Outdated Show resolved Hide resolved
@quagmt quagmt merged commit f71729f into master Nov 19, 2024
9 checks passed
@quagmt quagmt deleted the feat/add-PowToIntPart branch November 19, 2024 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants