[ruby-core:91151] [Ruby trunk Bug#15544] sprintf returns an unexpected string

From: shevegen@...
Date: 2019-01-17 22:28:38 UTC
List: ruby-core #91151
Issue #15544 has been updated by shevegen (Robert A. Heiler).


You should use the bugtracker primarily for ruby-related problems, issues and so forth. For questions
about C not directly related to the ruby implementation, stackoverflow may be a better site.

----------------------------------------
Bug #15544: sprintf returns an unexpected string
https://bugs.ruby-lang.org/issues/15544#change-76382

* Author: areman01 (Andr辿 Kullmann)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Hello,

I've a little problem with the sprintf function. It returns unexpected results ( in my opinion )

``` ruby
sprintf("%.16g", 8.78)
# returns "8.779999999999999"
# my expected result is "8.78"
```

Can somebody explain this behavior to me ?

Best Begards



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next