\hypertarget{interfacedc__string_1_1roundnum}{}\section{dc\+\_\+string\+:\+:roundnum Interface Reference}
\label{interfacedc__string_1_1roundnum}\index{dc\+\_\+string\+::roundnum@{dc\+\_\+string\+::roundnum}}
\subsection*{Private Member Functions}
\begin{DoxyCompactItemize}
\item 
character(string) function \hyperlink{interfacedc__string_1_1roundnum_ae8793bfc2d9fa817d2e1b933d3875048}{roundnum} (num)
\end{DoxyCompactItemize}


\subsection{Detailed Description}


Definition at line 86 of file dc\+\_\+string.\+f90.



\subsection{Constructor \& Destructor Documentation}
\mbox{\Hypertarget{interfacedc__string_1_1roundnum_ae8793bfc2d9fa817d2e1b933d3875048}\label{interfacedc__string_1_1roundnum_ae8793bfc2d9fa817d2e1b933d3875048}} 
\index{dc\+\_\+string\+::roundnum@{dc\+\_\+string\+::roundnum}!roundnum@{roundnum}}
\index{roundnum@{roundnum}!dc\+\_\+string\+::roundnum@{dc\+\_\+string\+::roundnum}}
\subsubsection{\texorpdfstring{roundnum()}{roundnum()}}
{\footnotesize\ttfamily character(string) function dc\+\_\+string\+::roundnum\+::roundnum (\begin{DoxyParamCaption}\item[{character($\ast$), intent(in)}]{num }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 1408 of file dc\+\_\+string.\+f90.


\begin{DoxyCode}
1408     \textcolor{comment}{!}
1409     \textcolor{comment}{! '0.30000001' や '12.999998' などの丸め誤差によって端数が残って}
1410     \textcolor{comment}{! しまっている数値表記を '0.3' や '13.' などに整形して返します.}
1411     \textcolor{comment}{!}
1412     \textcolor{keywordtype}{character(*)}, \textcolor{keywordtype}{intent(in)}:: num
1413     \textcolor{keywordtype}{character(STRING)}:: nrv, enrv
1414     \textcolor{keywordtype}{integer}:: i, moving\_up, nrvi, dig, zero\_stream
1415   \textcolor{keywordflow}{continue}
1416     \textcolor{comment}{!}
1417     \textcolor{comment}{! 実数でないものについてはそのまま返す.}
1418     \textcolor{comment}{!}
1419     \textcolor{keywordflow}{if} ( scan(\textcolor{stringliteral}{'.'}, trim(num) ) == 0  ) \textcolor{keywordflow}{then}
1420       result = num
1421       \textcolor{keywordflow}{return}
1422 \textcolor{keywordflow}{    end if}
1423     nrv = num
1424 
1425     \textcolor{comment}{!}
1426     \textcolor{comment}{! 指数部を避けておく.}
1427     \textcolor{comment}{!}
1428     enrv = \textcolor{stringliteral}{''}
1429     i = scan(nrv, \textcolor{stringliteral}{"eE"}, back=.true.)
1430     \textcolor{keywordflow}{if} ( i > 1  ) \textcolor{keywordflow}{then}
1431       enrv = nrv(i:)
1432       nrv(i:) = \textcolor{stringliteral}{" "}
1433     \textcolor{keywordflow}{elseif} ( i == 1 ) \textcolor{keywordflow}{then}
1434       result = nrv
1435       \textcolor{keywordflow}{return}
1436 \textcolor{keywordflow}{    end if}
1437 
1438     \textcolor{comment}{!}
1439     \textcolor{comment}{! 0.30000001 などの末尾の 1 のような, ゴミの桁の数値を掃除し,}
1440     \textcolor{comment}{! 0.3000000 などに整形.}
1441     \textcolor{comment}{!}
1442     \textcolor{keywordflow}{if} ( index( trim( nrv ), \textcolor{stringliteral}{'.'}) - len\_trim( nrv ) < -7 ) \textcolor{keywordflow}{then}
1443       \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} ( index(\textcolor{stringliteral}{'567890.'}, nrv(len\_trim(nrv):len\_trim(nrv)) ) == 0 )
1444         \textcolor{keywordflow}{if} ( len\_trim(nrv) < 2 ) \textcolor{keywordflow}{exit}
1445         nrv = nrv(1:len\_trim(nrv)-1)
1446 \textcolor{keywordflow}{      end do}
1447 \textcolor{keywordflow}{    end if}
1448 
1449     \textcolor{comment}{!}
1450     \textcolor{comment}{! 0.30000001986 などの末尾の 1 以降のゴミの桁の数値を掃除し,}
1451     \textcolor{comment}{! 0.3000000 などに整形.}
1452     \textcolor{comment}{!}
1453     \textcolor{keywordflow}{if} ( index( trim( nrv ), \textcolor{stringliteral}{'.'}) - len\_trim( nrv ) < -7 ) \textcolor{keywordflow}{then}
1454       dig = index( trim( nrv ), \textcolor{stringliteral}{'.'}) + 1
1455       zero\_stream = 0
1456       \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} ( dig < len\_trim( nrv ) )
1457         \textcolor{keywordflow}{if} ( nrv(dig:dig) == \textcolor{stringliteral}{"0"} ) \textcolor{keywordflow}{then}
1458           zero\_stream = zero\_stream + 1
1459         \textcolor{keywordflow}{else}
1460           zero\_stream = 0
1461 \textcolor{keywordflow}{        end if}
1462         \textcolor{keywordflow}{if} ( zero\_stream > 7 ) \textcolor{keywordflow}{then}
1463           nrv(dig:len\_trim(nrv)) = \textcolor{stringliteral}{'0'}
1464           \textcolor{keywordflow}{exit}
1465 \textcolor{keywordflow}{        end if}
1466         dig = dig + 1
1467 \textcolor{keywordflow}{      end do}
1468 \textcolor{keywordflow}{    end if}
1469 
1470     \textcolor{comment}{!}
1471     \textcolor{comment}{! 0.3000000 などの末尾の 0 を掃除し,}
1472     \textcolor{comment}{! 0.3 などに整形.}
1473     \textcolor{comment}{!}
1474     \textcolor{keywordflow}{if} ( index( trim( nrv ), \textcolor{stringliteral}{'.'}) /= 0 ) \textcolor{keywordflow}{then}
1475       \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} ( index(\textcolor{stringliteral}{'123456789.'}, nrv(len\_trim(nrv):len\_trim(nrv)) ) == 0 )
1476         \textcolor{keywordflow}{if} ( len\_trim(nrv) < 2 ) \textcolor{keywordflow}{exit}
1477         nrv = nrv(1:len\_trim(nrv)-1)
1478 \textcolor{keywordflow}{      end do}
1479 \textcolor{keywordflow}{    end if}
1480 
1481     \textcolor{comment}{!}
1482     \textcolor{comment}{! 0.89999998 などの末尾の 8 のような, ゴミの桁の数値を掃除し,}
1483     \textcolor{comment}{! 0.8999999 などに整形.}
1484     \textcolor{comment}{!}
1485     moving\_up = 0
1486     \textcolor{keywordflow}{if} ( index( trim( nrv ), \textcolor{stringliteral}{'.'}) - len\_trim( nrv ) < -7 ) \textcolor{keywordflow}{then}
1487       \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} ( index(\textcolor{stringliteral}{'12345690.'}, nrv(len\_trim(nrv):len\_trim(nrv)) ) == 0 )
1488         \textcolor{keywordflow}{if} ( len\_trim(nrv) < 2 ) \textcolor{keywordflow}{exit}
1489         nrv = nrv(1:len\_trim(nrv)-1)
1490 \textcolor{keywordflow}{      end do}
1491       moving\_up = 1
1492 \textcolor{keywordflow}{    end if}
1493 
1494     \textcolor{comment}{!}
1495     \textcolor{comment}{! 0.8999999 などの末尾の 9 を掃除し, 繰り上げて}
1496     \textcolor{comment}{! 0.9 などに整形.}
1497     \textcolor{comment}{!}
1498     \textcolor{keywordflow}{if} ( moving\_up > 0 ) \textcolor{keywordflow}{then}
1499       \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} ( index(\textcolor{stringliteral}{'012345678.'}, nrv(len\_trim(nrv):len\_trim(nrv)) ) == 0 )
1500         \textcolor{keywordflow}{if} ( len\_trim(nrv) < 2 ) \textcolor{keywordflow}{exit}
1501         nrv = nrv(1:len\_trim(nrv)-1)
1502 \textcolor{keywordflow}{      end do}
1503 \textcolor{keywordflow}{    end if}
1504 
1505     i = len\_trim(nrv)
1506     \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} ( moving\_up > 0 .and. i > 0 )
1507       \textcolor{keywordflow}{if} ( index(\textcolor{stringliteral}{'.'}, nrv(i:i)) /= 0 ) \textcolor{keywordflow}{then}
1508         i = i - 1
1509         cycle
1510 \textcolor{keywordflow}{      end if}
1511       nrvi = \hyperlink{interfacedc__string_1_1stoi}{stoi}( nrv(i:i) ) + moving\_up
1512 
1513       \textcolor{keywordflow}{if} ( nrvi < 10 ) \textcolor{keywordflow}{then}
1514         nrv(i:i) = trim( \hyperlink{interfacedc__string_1_1tochar}{tochar}( nrvi ) )
1515         \textcolor{keywordflow}{exit}
1516       \textcolor{keywordflow}{else}
1517         nrv(i:i) = \textcolor{stringliteral}{'0'}
1518         \textcolor{keywordflow}{if} ( i < 2 ) \textcolor{keywordflow}{then}
1519           nrv = \textcolor{stringliteral}{'10'}
1520           \textcolor{keywordflow}{exit}
1521         \textcolor{keywordflow}{else}
1522           i = i - 1
1523           cycle
1524 \textcolor{keywordflow}{        end if}
1525 \textcolor{keywordflow}{      end if}
1526       \textcolor{keywordflow}{if} ( len\_trim(nrv) < 2 ) \textcolor{keywordflow}{exit}
1527       nrv = nrv(1:len\_trim(nrv)-1)
1528 \textcolor{keywordflow}{    end do}
1529 
1530     \textcolor{comment}{!}
1531     \textcolor{comment}{! 0.3000000 などの末尾の 0 を掃除し,}
1532     \textcolor{comment}{! 0.3 などに整形.}
1533     \textcolor{comment}{!}
1534     \textcolor{keywordflow}{if} ( index( trim( nrv ), \textcolor{stringliteral}{'.'}) /= 0 ) \textcolor{keywordflow}{then}
1535       \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} ( index(\textcolor{stringliteral}{'123456789.'}, nrv(len\_trim(nrv):len\_trim(nrv)) ) == 0 )
1536         \textcolor{keywordflow}{if} ( len\_trim(nrv) < 2 ) \textcolor{keywordflow}{exit}
1537         nrv = nrv(1:len\_trim(nrv)-1)
1538 \textcolor{keywordflow}{      end do}
1539 \textcolor{keywordflow}{    end if}
1540 
1541     \textcolor{comment}{!}
1542     \textcolor{comment}{! 指数部を復帰する}
1543     \textcolor{comment}{!}
1544     \textcolor{keywordflow}{if} ( len\_trim(enrv) > 0 ) \textcolor{keywordflow}{then}
1545       nrv = trim(nrv) // enrv
1546 \textcolor{keywordflow}{    end if}
1547 
1548     result = nrv
\end{DoxyCode}


The documentation for this interface was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
dc\+\_\+utils/\hyperlink{dc__string_8f90}{dc\+\_\+string.\+f90}\end{DoxyCompactItemize}
