Skip to content

power operator block a^b#3462

Open
AeroKoder wants to merge 1 commit intoscratchfoundation:developfrom
AeroKoder:operator_power
Open

power operator block a^b#3462
AeroKoder wants to merge 1 commit intoscratchfoundation:developfrom
AeroKoder:operator_power

Conversation

@AeroKoder
Copy link

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 1 or NaN. Currently, it returns 1, as that is what the native JavaScript operator returns. This might confuse younger Scratchers, but then again, I don't know if NaN is 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 scratchfoundation/scratch-editor#444

Test Coverage

Tests are in the scratchfoundation/scratch-editor#444

@redspacecat
Copy link

ah, a new PR was made

@AeroKoder

This comment was marked as off-topic.

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