Project

General

Profile

Actions

Bug #15544

closed

sprintf returns an unexpected string

Added by areman01 (André Kullmann) almost 4 years ago. Updated almost 4 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
[ruby-core:91142]

Description

Hello,

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

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

Can somebody explain this behavior to me ?

Best Begards

Updated by shevegen (Robert A. Heiler) almost 4 years ago

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.

Updated by shyouhei (Shyouhei Urabe) almost 4 years ago

  • Status changed from Open to Rejected

Please visit https://bugs.ruby-lang.org/ and read the FAQ part.
Next time consider doing so before posting an issue.

Actions

Also available in: Atom PDF

Like0
Like0Like0