You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2021/02/10 13:12:00 UTC
[jira] [Work logged] (LANG-1444) NumberUtils.createNumber() does
not create BigDecimal for decimal fractions tending to zero
[ https://issues.apache.org/jira/browse/LANG-1444?focusedWorklogId=550705&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-550705 ]
ASF GitHub Bot logged work on LANG-1444:
----------------------------------------
Author: ASF GitHub Bot
Created on: 10/Feb/21 13:11
Start Date: 10/Feb/21 13:11
Worklog Time Spent: 10m
Work Description: bndhanush commented on pull request #675:
URL: https://github.com/apache/commons-lang/pull/675#issuecomment-776695814
@chtompki and @garydgregory.
Can you please help in checking if the PR is valid. Also suggest if any changes are required.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Issue Time Tracking
-------------------
Worklog Id: (was: 550705)
Time Spent: 1h 20m (was: 1h 10m)
> NumberUtils.createNumber() does not create BigDecimal for decimal fractions tending to zero
> -------------------------------------------------------------------------------------------
>
> Key: LANG-1444
> URL: https://issues.apache.org/jira/browse/LANG-1444
> Project: Commons Lang
> Issue Type: Bug
> Components: lang.math.*
> Affects Versions: 3.8.1
> Reporter: Costa Theodosiou
> Priority: Major
> Time Spent: 1h 20m
> Remaining Estimate: 0h
>
> The following code demonstrates the issue:
> {{System.out.println(NumberUtils.createNumber("1.1").getClass().getName());}}
> {{System.out.println(NumberUtils.createNumber("1.001").getClass().getName());}}
> {{System.out.println(NumberUtils.createNumber("1.00001").getClass().getName());}}
> {{System.out.println(NumberUtils.createNumber("1.0000001").getClass().getName());}}
> {{System.out.println(NumberUtils.createNumber("1.000000001").getClass().getName());}}
> {{System.out.println(NumberUtils.createNumber("1.00000000001").getClass().getName());}}
> {{System.out.println(NumberUtils.createNumber("1.0000000000001").getClass().getName());}}
> {{System.out.println(NumberUtils.createNumber("1.000000000000001").getClass().getName());}}
> {{System.out.println(NumberUtils.createNumber("1.00000000000000001").getClass().getName());}}
> {{System.out.println(NumberUtils.createNumber("1.0000000000000000001").getClass().getName());}}
> {{System.out.println(NumberUtils.createNumber("1.000000000000000000001").getClass().getName());}}
> {{System.out.println(NumberUtils.createNumber("1.00000000000000000000001").getClass().getName());}}
> will print:
> {{java.lang.Float}}
> {{java.lang.Float}}
> {{java.lang.Float}}
> {{java.lang.Float}}
> {{java.lang.Double}}
> {{java.lang.Double}}
> {{java.lang.Double}}
> {{java.lang.Double}}
> {{java.lang.Float}}
> {{java.lang.Float}}
> {{java.lang.Float}}
> {{java.lang.Float}}
> It seems the problem is towards the bottom of the createNumber method that compares the float to double string representation:
> f.toString().equals(d.toString())
> For the misbehaving tests, the string "1.0".equals("1.0")
--
This message was sent by Atlassian Jira
(v8.3.4#803005)