power operator block a^b#3431
Open
AeroKoder wants to merge 1 commit intoscratchfoundation:developfrom
Open
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
This comment was marked as resolved.
This comment was marked as resolved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves
scratchfoundation/scratch-editor#426
Proposed Changes
Add a new block to the Operator category to raise a given number to a power of another given number.
Reason for Changes
This is a highly requested block by many Scratchers and Scratch Team members (I have with some [1,2], and they agree that it should exist in Scratch). There also aren't any accurate workarounds, besides ones that are crazy inefficient, making this block even more important to have.
It has been discussed in multiple topics and issues, and they always end up with tons of upvotes and supports.
The one thing I would like to discuss is whether, zero to the power of zero, should return
1orNaN. Currently, it returns1, as that is what the native JavaScript operator returns. This might confuse younger Scratchers, but then again, I don't know ifNaNis such a good idea either, since it acts as zero in scratch, making some math equations with the power operator return an incorrect result. Discuss this in the scratch-editor PRTest Coverage
Tests are in the scratch-editor PR