bc

bc cannot handle "comma" instead of "dot" in floating point operations

Bug #1589717 reported by benjamin button
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
bc
Fix Released
Unknown
bc (Ubuntu)
Won't Fix
High
Unassigned

Bug Description

Using comma in floating point arithmetic operations causing problem in bc.

Can be reproduced by using following command;
bc <<< "100 - 97,2"

It is running without an error if comma is replaced by dot as following;
bc <<< "100 - 97.2"

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: bc 1.06.95-9build1
ProcVersionSignature: Ubuntu 4.4.0-22.40-generic 4.4.8
Uname: Linux 4.4.0-22-generic x86_64
ApportVersion: 2.20.1-0ubuntu2.1
Architecture: amd64
CurrentDesktop: XFCE
Date: Tue Jun 7 01:17:11 2016
InstallationDate: Installed on 2016-06-05 (1 days ago)
InstallationMedia: Xubuntu 16.04 LTS "Xenial Xerus" - Release amd64 (20160420.1)
SourcePackage: bc
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
benjamin button (canavaroski90) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in bc (Ubuntu):
status: New → Confirmed
Changed in bc (Ubuntu):
importance: Undecided → High
Revision history for this message
benjamin button (canavaroski90) wrote :

I believe decimal separator symbol varies from region to region, so is there any way to get the correct decimal separator?

I can now clearly see that this bug is valid if "bc" cannot get (or convert) the correct decimal separator. Is there any other bug(s) that prevents bc to get the correct symbol? Because user selects the region and country information at the installing screen on most distros. Hence the system should know which decimal point separator will be used as default.

I don't see any necessity to support different decimal separator symbols. If there is no counter-argument, I would like to mark this bug as "WON'T FIX".

Revision history for this message
Ryan Kavanagh (ryanakca) wrote :

Thanks for the bug report. However, the use of a period instead of a locale-dependent separator is deliberate, bc was so-designed for good reason, and this choice is specified by POSIX. Indeed, the POSIX man page for bc(1) specifies:

       The bc utility always uses the <period> ('.') character to represent a radix point,
       regardless of any decimal-point character specified as part of the current locale.

See the rest of the section "APPLICATION USAGE" on https://www.unix.com/man-page/posix/1P/bc/ for a rationale as to why the period is used.

Changed in bc (Ubuntu):
status: Confirmed → Won't Fix
Changed in bc:
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.