Bug 162495 - dc(1): dc -e "5 3 %p 1k 5 3 %p"
Summary: dc(1): dc -e "5 3 %p 1k 5 3 %p"
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: Alan Somers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-11 22:10 UTC by John Smith
Modified: 2017-12-07 02:10 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Smith 2011-11-11 22:10:05 UTC
/usr/src/usr.bin/dc/

%dc -e "5 3 %p 1k 5 3 %p"
2
.2

Output of the modulo operator is divided by 10(scale) when scale>0.

From what I tested the bug doesn't appear to happen in bcode.c:bmod(void), it looks like it happens some time after it is called.

How-To-Repeat: %dc -e "5 3 %p 1k 5 3 %p"
2
.2
Comment 1 commit-hook freebsd_committer freebsd_triage 2017-12-07 02:09:03 UTC
A commit references this bug:

Author: asomers
Date: Thu Dec  7 02:08:56 UTC 2017
New revision: 326652
URL: https://svnweb.freebsd.org/changeset/base/326652

Log:
  dc(1): fix modulo operations with fractional inputs

  Our dc(1) has never correctly calculated remainders with fractional inputs.
  Both bmod and bdivmod seem to have copy/pasted code from bdiv, which results
  in the remainder having the wrong output scale.

  PR:		162495
  Reported by:	anonymous
  Reviewed by:	pfg
  Differential Revision:	https://reviews.freebsd.org/D13390

Changes:
  head/usr.bin/dc/bcode.c
  head/usr.bin/dc/dc.1
  head/usr.bin/dc/tests/Makefile
  head/usr.bin/dc/tests/bcode.sh
  head/usr.bin/dc/tests/inout.sh