 aaa
aaa
aaa
aaa
aaa
aaa
aaa

#### 로그아웃

0
(/p/c)
I want representation scientific exponential notation in C++ but i have problem while make a coding exponential notation in c++ in result -> 0.14245..

I want representation scientific exponential notation in C++

but i have problem while make a coding exponential notation in c++

in result -> 0.142456e14

but i want make this result -> 0.142424256645767E014

how can i make get above result(representation)

• fraction position 2(XX)-> 3(0XX) , e->E , significant note : 6 -> 15 position

C++ scientific exponential notation 관련 초보자 질문

0
(/p/c)
I want representation scientific exponential notation in C++ but i have problem while make a coding exponential notation in c++ in result -> 0.14245..

I want representation scientific exponential notation in C++

but i have problem while make a coding exponential notation in c++

in result -> 0.142456e14

but i want make this result -> 0.142424256645767E014

how can i make get above result(representation)

• fraction position 2(XX)-> 3(0XX) , e->E , significant note : 6 -> 15 position

댓글 쓰기

#### 2개의 답변

1
(/p/c)
원하시는 답변인지 모르겠습니다만 아래 코드가 참고가 되시길 바랍니다. #include #include #include #include #include int main() { double c = ..

원하시는 답변인지 모르겠습니다만 아래 코드가 참고가 되시길 바랍니다.

``````#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <algorithm>

int main()
{
double c = 1424242566457123;
std::stringstream ss;
ss.setf(std::ios_base::scientific | std::ios_base::uppercase);
ss << std::setprecision(15) << c;
auto number = ss.str();

size_t pos = number.size() - 3;
if ( !std::isdigit(int(number[pos])) )
{
if ( number[pos] == 'E' )
number.insert(pos + 1, "0");
else
number.insert(pos + 1, 1, '0');
}

std::cout << number << '\n';
}``````

결과

``1.424242566457123E+015``

댓글 쓰기
0
(/p/c)
그 E뒤에 세자리수로 나오게 하고 싶읍니다..

그 E뒤에 세자리수로 나오게 하고 싶읍니다..

댓글 쓰기
조회수 302
답글 2
URL