Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

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.)

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 submission for the challenge Calculate 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.)

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 submission for the challenge Calculate 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.)

Tweeted twitter.com/StackCodeGolf/status/778347508242219008
Source Link
juh
  • 983
  • 4
  • 8

May `dc` take negative input as it's designed to?

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 submission for the challenge Calculate 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.)