# Patterns.number and pi, e, etc

Something’s not working the way it seems like it should.

When I …
use patterns.number to check if pi is a number, patterns thinks pi is not a number. Same thing with e

I saw …

But I expected …
patterns.number should match pi as a number since, well, it is a number.

Here’s the link to the page, dashboard, or activity:

And here are some screenshots or a video:

Thanks for the report Mike!

This isn’t a bug, just a choice made when the patterns system was designed. It’s similar to how the fraction 1/2 isn’t picked up by the number pattern, and allows authors to have finer control over how they handle inputs.

Here’s a pattern we often use in lessons to pick up a wide variety of numbers:

p = patterns

wholeNumber = p.integer
special = p.anyOf(p.literal(\pi), p.literal(e), p.literal(\tau))
reasonableNumber = p.product(p.optional(wholeNumber), p.optional(special))
Fraction = p.anyOf(p.fraction(reasonableNumber, wholeNumber), p.fraction(wholeNumber, reasonableNumber))

Number = p.anyOf(
reasonableNumber, p.fraction(reasonableNumber,wholeNumber),
p.fraction(wholeNumber, reasonableNumber),