Bug 12336 - bc: bug in comparing negative numbers
Summary: bc: bug in comparing negative numbers
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: All Linux
: P5 major
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-21 17:58 UTC by Eugene Gladchenko
Modified: 2019-11-23 16:25 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
Fix a bug in comparing negative numbers (338 bytes, patch)
2019-11-21 17:58 UTC, Eugene Gladchenko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Gladchenko 2019-11-21 17:58:59 UTC
Created attachment 8291 [details]
Fix a bug in comparing negative numbers

Hi,

There's a bug in comparing negative numbers via bc calculator.
When the number of significant figures differs it gives the wrong result.

$ bc
bc 1.32.0.git
Adapted from https://github.com/gavinhoward/bc
Original code (c) 2018 Gavin D. Howard and contributors
-11 < -10
1
-10 < -9
0

The patch is trivial (attached).

The original code by Gavin Howard has this bug as well, hopefully it will be fixed soon (pull request submitted).

Regards,
Eugene Gladchenko
Comment 1 Natanael Copa 2019-11-22 08:15:06 UTC
We should also add a test for this in the testsuite.
Comment 2 Denys Vlasenko 2019-11-23 16:25:55 UTC
Fixed in git, thanks