A question about a factorial operator
retained text
<p>I wrote an assembler that supports floating point values. One of the operators I implemented was factorial because a lot of Taylor series seem to use it to define various constants. So right now, I have</p> <pre><code>.float -((2*3.14159265)**11)/11! </code></pre> <p>I found a bug in the parsing such that <code>(2+3)!</code> doesn't parse (the parsing of the factorial operator is in the wrong location). In fixing the bug, I found an issue that I don't know how best to resolve, since I personally have never used a programming language that defined a factorial operator. So my question: what should <code>-3!</code> produce? Should it error out as factorial isn't defined for negative numbers? Or should it parse as <code>-(3!)</code> and return -6? I ask because of <code>-(2+3)!</code>. What binds tighter? The minus, or the factorial?</p> Tags: ask, compilers
document fetched 2026-08-01 08:08