Работа с числами. Экспоненциальная запись.
- Войдите на сайт для отправки комментариев
Пнд, 08/01/2018 - 23:32
Доброго времени суток. Вопрос от новичка не судите строго. Допустим, получаем значения переменной float следующего вида 314000, 314, 0.000314, 0.00000314. Как можно преобразовать получающееся число в вид 3.14Е+5, 314E+00, 3.14Е-4, 3.14Е-6? На Википедии нашел, что это экспоненциальная запись, но в силу неопытности не знаю, как реализовать. Прошу помощи в реализации такой функции или информации по данному вопросу. За ранее спасибо!.
Потрясен! Пойду выпю чегонить..
Потрясен! Пойду выпю чегонить..
За образование! ...Не чокаясь!
The dtostre() function converts the double value passed in
val
into an ASCII representation that will be stored unders
. The caller is responsible for providing sufficient storage ins
.Conversion is done in the format
"[-]d.ddde±dd"
where there is one digit before the decimal-point character and the number of digits after it is equal to the precisionprec
; if the precision is zero, no decimal-point character appears. Ifflags
has the DTOSTRE_UPPERCASE bit set, the letter'E'
(rather than'e'
) will be used to introduce the exponent. The exponent always contains two digits; if the value is zero, the exponent is"00"
.If
flags
has the DTOSTRE_ALWAYS_SIGN bit set, a space character will be placed into the leading position for positive numbers.If
flags
has the DTOSTRE_PLUS_SIGN bit set, a plus sign will be used instead of a space character in this case.The dtostre() function returns the pointer to the converted string
s
.================================
На словах просили передать, что оно в <stdlib.h> .....
За образование! ...Не чокаясь!
Уж лучше за букву "А".
Спасибо большое, помогло!