Russ Cox is sharing code with you

Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.

Don't show this again

rsc / plan9port http://swtch.com/plan9port/

Plan 9 from User Space (aka plan9port) is a port of many Plan 9 programs from their native Plan 9 environment to Unix-like operating systems. See the web site http://swtch.com/plan9port/ for details.

Clone this repository (size: 58.2 MB): HTTPS / SSH
hg clone https://bitbucket.org/rsc/plan9port
hg clone ssh://hg@bitbucket.org/rsc/plan9port

Issues

#75 Bug in 'dc' input bases

Reported by Maurício CA

'dc' calculator allows changing the base for input and, separately, for output. In this example, 'i' changes base, 'I' puts base as a number at top of stack and 'p' prints top of stack.

% echo 16 i I p 15 i I p 14 i I p 10 i I p 8 i I p | dc
16
21
25
25
8

The correct output would be 16 15 14 10 8. Note that changing input base doesn't change output base, so, all that output is supposed to be base 10.

Status: invalid Responsible: nobody Type: bug Priority: major
Milestone: none Component: none Version: none

Attachments

No attachments added for this issue yet.

Comments and changes

  1. #1 Anthony Sorace

    written

    • Changed status from new to resolved.

    The demonstrated behavior is correct.

    Note that when you specify a base of "15", you're saying "15 in base 16" (which is equivalent to 21 in base 10), since that's what you've previously set the input base to. similarly for all subsequent cases until you get to 8, where 8 happens to be the same in your input and output bases.

    p is correctly printing in the (unmodified) base-10 representation of these numbers.

  2. #2 Anthony Sorace

    written

    • Changed status from resolved to invalid.

Add comment / attachment

Verification: Please write the text from the image in the box (letters only)

captcha

Is that you, Humanoid? Is this me?