Skip to content

Redefine certain behaviors (like 0^0) or "catch" operations like that #3171

Answered by josdejong
NullDev asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, it's me again with yet another weird question 👋

😂 hi!

You'll have to replace the implementation of math.pow with your own version, that handles the case of 0^0 like you want.

For example:

const originalPow = math.pow

function customPow(x, y) {
  if (math.isZero(x) && math.isZero(y)) {
    return undefined
  }
  
  return originalPow(x, y)
}

math.import({ pow: customPow }, { override: true })

console.log('result:', math.evaluate('0^0')) // undefined

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@NullDev
Comment options

Answer selected by NullDev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants