реклама на сайте
подробности

 
 
> Как sprintf() работает с float числами?
Александар
сообщение Apr 28 2008, 09:18
Сообщение #1





Группа: Новичок
Сообщений: 8
Регистрация: 28-08-07
Пользователь №: 30 106



Q правильно преобразуется, а E не понятно как.
в прикрепленном файле содержимое массива Str после выполнения функции.

#include <avr/io.h>
#include <stdio.h>

unsigned char Q=5;
char Str[16];
double E=2.15;
int main(void) //
{

sprintf(Str, "Q=%d E=%2.2f %s",Q, E, "FFF");
__asm__ volatile("nop");

}
Эскизы прикрепленных изображений
Прикрепленное изображение
 
Go to the top of the page
 
+Quote Post
 
Start new topic
Ответов
aesok
сообщение Apr 28 2008, 10:04
Сообщение #2


Знающий
****

Группа: Участник
Сообщений: 596
Регистрация: 26-05-06
Из: Москва
Пользователь №: 17 484



RTFM:
Цитата
Since the full implementation of all the mentioned features becomes fairly large, three different flavours of vfprintf() can be selected using linker options. The default vfprintf() implements all the mentioned functionality except floating point conversions. A minimized version of vfprintf() is available that only implements the very basic integer and string conversion facilities, but only the # additional option can be specified using conversion flags (these flags are parsed correctly from the format specification, but then simply ignored). This version can be requested using the following compiler options:


-Wl,-u,vfprintf -lprintf_min

If the full functionality including the floating point conversions is required, the following options should be used:


-Wl,-u,vfprintf -lprintf_flt -lm


Анатолий

Сообщение отредактировал aesok - Apr 28 2008, 10:06
Go to the top of the page
 
+Quote Post



Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 23rd July 2025 - 04:10
Рейтинг@Mail.ru


Страница сгенерированна за 0.01349 секунд с 7
ELECTRONIX ©2004-2016