[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-dev] [bug #38614] dtostrf - wrong behavior or wrong documentat
From: |
Anton |
Subject: |
[avr-libc-dev] [bug #38614] dtostrf - wrong behavior or wrong documentation |
Date: |
Thu, 28 Mar 2013 07:54:28 +0000 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22 |
URL:
<http://savannah.nongnu.org/bugs/?38614>
Summary: dtostrf - wrong behavior or wrong documentation
Project: AVR C Runtime Library
Submitted by: demiurg_spb
Submitted on: Чтв 28 Мар 2013 07:54:26
Category: Library
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: libc code
Status: None
Percent Complete: 0%
Assigned to: None
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: 1.8.0
Fixed Release: None
_______________________________________________________
Details:
I have next situation:
Code:
float value = 0.0f;
char buf[32];
static const int WIDTH = 3;
static const int PREC = 0;
dtostrf(value, WIDTH, PREC, buf);
I get {' ',' ','0'} // space, space, zero
but I expected {' ','0','.'} // space, zero, point
because of manual:
Quote:
The minimum field width of the output string (including the '.' and the
possible sign for negative values) is given in width, and prec determines the
number of digits after the decimal sign. width is signed value, negative for
left adjustment.
I think manual sholud be corrected:
Quote:
The minimum field width of the output string (including the possible '.' and
the possible sign for negative values) is given in width, and prec determines
the number of digits after the decimal sign. width is signed value, negative
for left adjustment.
Jörg Wunsch comment from avrfreaks:
That's debatable. It would seem reasonable to correct the function
itself, so it yields " 0." rather than " 0", to indicate this is
a floating-point number. Then, it would also be debatable how to
handle numbers where the absolute value is less than one: print
" .1", or better " 0.1"?
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/bugs/?38614>
_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-libc-dev] [bug #38614] dtostrf - wrong behavior or wrong documentation,
Anton <=