Bug 12336

Summary: bc: bug in comparing negative numbers
Product: Busybox Reporter: Eugene Gladchenko <gladchenko>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: major CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:
Attachments: Fix a bug in comparing negative numbers

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