In the language dc
, the -
character is reserved strictly for subtraction, so it cannot be used to enter a negative number. An alternative format for entering negative numbers was created: precede the number with an underscore, as in _5
. Many challenges require submissions to accept negative input.
This may be a trivial question, but I want to know whether dc
is allowed to take negative input with underscores rather than minuses. As an example, in my submissionsubmission for the challenge Calculate the sum of ILDCalculate the sum of ILD, I left a buffer of numbers waiting on the stack to receive a leading -
and report back whether the number was negative. Instead, I'd prefer to just assume that the number will be input as negative in the manner recognised by the interpreter. (I don't intend to change that particular submission; I'm just asking for future reference.)