-
Notifications
You must be signed in to change notification settings - Fork 26
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
Adding arithmetic computation: Power. #6
base: master
Are you sure you want to change the base?
Conversation
README.md
Outdated
@@ -39,6 +39,7 @@ $ yarn test | |||
- [Subtract](src/subtract/index.d.ts) - subtracts two numbers. | |||
- [Multiply](src/multiply/index.d.ts) - multiplies two numbers. | |||
- [Divide](src/divide/index.d.ts) - divides two numbers. | |||
- [Power](src/power/index.d.ts) - computes A power B. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about computes the given base taken to the power of the given exponent
?
src/power/index.d.ts
Outdated
@@ -0,0 +1,32 @@ | |||
import { Multiply, Dec, Cast } from '..'; | |||
|
|||
// Power two numbers: https://lodash.com/docs/4.17.15#power. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be the same description as in the README.md. Also, this URL doesn't lead anywhere, how about we use https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow instead?
src/power/index.d.ts
Outdated
// This type uses recursive (and not officially supported) type alias, see more: | ||
// https://github.com/microsoft/TypeScript/issues/26223#issuecomment-513187373. | ||
export type Power< | ||
// The first number in a multiplication. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think multiplication
is a mistake, how about The base number
?
// https://github.com/microsoft/TypeScript/issues/26223#issuecomment-513187373. | ||
export type Power< | ||
// The first number in a multiplication. | ||
A extends number, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be B
(short for base).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it breaks the consistency of other arithmetic computations in the project where A is always the first number of the evaluation (like in normal calculators)
src/power/index.d.ts
Outdated
export type Power< | ||
// The first number in a multiplication. | ||
A extends number, | ||
// The second number in a multiplication. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a mistake too, how about The exponent used to raise the base
?
// The first number in a multiplication. | ||
A extends number, | ||
// The second number in a multiplication. | ||
B extends number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be E
(short for exponent).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR 🏆, please see my comments 🙏
@ronami I made the needed changes :) |
Hey Ronen, I wish to support the meta-typing effort by adding a new arithmetic computation!