While I use %gthe format c as a specifier printf(), sometimes it is rounded to 2 places after the decimal point, sometimes to 3 places, sometimes to 4 places ... how does this happen?
%g
printf()
Actually, where should we use %ginstead of %for %efor floating point numbers?
%f
%e
The format specifier %gdoes its rounding exactly as it does, %fbut if it %fresults in 4.234000, then it %gwill omit trailing zeros and print 4.234.
4.234000
4.234
%g , , 12345.6, 1.235e04.
12345.6
1.235e04
%g "" %e %f , , , . , %g .
%f "" , %g .6 .
printf:
" f e ( F E G). . , 6 ; , 1. e -4 . ; .
"RTFM", , , , .
Source: https://habr.com/ru/post/1767529/More articles:How to use the z-index in the ? - cssIs it possible to create a * .config file from scratch programmatically in .NET (C #)? - c #Retrieving Data from BattleNet - data-retrievalhow to enable python modules on linux? - pythonjavascript testing if value is in an array - javascripthttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1767530/can-i-format-data-that-is-to-be-written-in-csv-file-using-java&usg=ALkJrhgmmgby7Pe8xqczvO_Q9-Qmcmyo4gIs Application.DoEvents () my only choice (in this case)? - c #CakePHP: editing only data fields - phpAnt inheritance of Maven properties - maven-2Using SVG + Java to flexibly display information, is it viable? - javaAll Articles