diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2017-06-19 11:29:20 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2017-06-19 11:29:20 -0700 |
commit | 1c2d788b454670bf8fa1cb65c6251a8ff6ddcaf7 (patch) | |
tree | fb858c9ac49152af7cfdd956c12870206cc18c72 /html/015literal_noninteger.cc.html | |
parent | b755631561fd1a9223effcc833e2c8201582f63d (diff) | |
download | mu-1c2d788b454670bf8fa1cb65c6251a8ff6ddcaf7.tar.gz |
3927
Diffstat (limited to 'html/015literal_noninteger.cc.html')
-rw-r--r-- | html/015literal_noninteger.cc.html | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/html/015literal_noninteger.cc.html b/html/015literal_noninteger.cc.html index f4efa035..f53cba44 100644 --- a/html/015literal_noninteger.cc.html +++ b/html/015literal_noninteger.cc.html @@ -83,11 +83,11 @@ if ('onhashchange' in window) { <span id="L20" class="LineNr">20 </span> <span class="Identifier">return</span> s<span class="Delimiter">.</span>find_first_not_of<span class="Delimiter">(</span><span class="Constant">"0123456789-."</span><span class="Delimiter">)</span> == string::npos <span class="Comment">// no other characters</span> <span id="L21" class="LineNr">21 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> && s<span class="Delimiter">.</span>find_first_of<span class="Delimiter">(</span><span class="Constant">"0123456789"</span><span class="Delimiter">)</span> != string::npos <span class="Comment">// at least one digit</span> <span id="L22" class="LineNr">22 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> && s<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">'-'</span><span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">)</span> == string::npos <span class="Comment">// '-' only at first position</span> -<span id="L23" class="LineNr">23 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> && std::count<span class="Delimiter">(</span>s<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> s<span class="Delimiter">.</span><a href='003trace.cc.html#L185'>end</a><span class="Delimiter">(),</span> <span class="Constant">'.'</span><span class="Delimiter">)</span> == <span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// exactly one decimal point</span> +<span id="L23" class="LineNr">23 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> && std::count<span class="Delimiter">(</span>s<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> s<span class="Delimiter">.</span><a href='003trace.cc.html#L197'>end</a><span class="Delimiter">(),</span> <span class="Constant">'.'</span><span class="Delimiter">)</span> == <span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// exactly one decimal point</span> <span id="L24" class="LineNr">24 </span><span class="Delimiter">}</span> <span id="L25" class="LineNr">25 </span> <span id="L26" class="LineNr">26 </span><span class="Normal">double</span> <a href='015literal_noninteger.cc.html#L26'>to_double</a><span class="Delimiter">(</span>string n<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L27" class="LineNr">27 </span> <span class="Normal">char</span>* <a href='003trace.cc.html#L185'>end</a> = <span class="Constant">NULL</span><span class="Delimiter">;</span> +<span id="L27" class="LineNr">27 </span> <span class="Normal">char</span>* <a href='003trace.cc.html#L197'>end</a> = <span class="Constant">NULL</span><span class="Delimiter">;</span> <span id="L28" class="LineNr">28 </span> <span class="Comment">// safe because string.c_str() is guaranteed to be null-terminated</span> <span id="L29" class="LineNr">29 </span> <span class="Normal">double</span> result = strtod<span class="Delimiter">(</span>n<span class="Delimiter">.</span>c_str<span class="Delimiter">(),</span> &end<span class="Delimiter">);</span> <span id="L30" class="LineNr">30 </span> assert<span class="Delimiter">(</span>*end == <span class="cSpecial">'\0'</span><span class="Delimiter">);</span> |