Talk:Dc (computer program): Difference between revisions

Content deleted Content added
m Fixed Lint errors on this page (obsolete/unclosed tags)
 
Line 9:
 
Wouldn't it be better to use an example that actually works? Because when I type <br/>
<tt>{{mono|1=12 3 4 ^ + _11 / v 22 -</tt>}}<br/>
I get<br/>
<tt>{{mono|1=dc: square root of negative number</tt>}}<br />
 
You miss-typed the example, the correct one is <br />
<tt>{{mono|1= 12 _3 4 ^ + 11 / v 22 -</tt>}}<br/>
After command <tt>{{mono|1=p<tt>}} you get<br />
<tt>{{mono|1=-20</tt>}} [[User:Annie Yousar|Annie Yousar]] ([[User talk:Annie Yousar|talk]]) 14:14, 15 March 2025 (UTC)
 
== Explanation ==
Can someone explain how the following works?<br />
<tt>{{mono|1=[q]sa[ln0=aln80~Psnlbx]16isb572CCB9AE9DB03273snlbxq</tt>}}
 
: It encodes the email address in the hex constant <tt>{{mono|1=n=0x572CCB9AE9DB03273</tt>}} and operates on it with the macro <tt>{{mono|1=b</tt>}} defined as <tt>{{mono|1=[ln0=aln80~Psnlbx]</tt>}}. This recursively calls itself until <tt>{{mono|1=n</tt>}} is equal to zero. -- [[User:Autopilot|Autopilot]] ([[User talk:Autopilot|talk]]) 22:44, 15 May 2010 (UTC)
 
: Just did a small optimization (in code length) to it: <tt>{{mono|1=[q]sa[d0=a80~anlbx]16isb572CCB9AE9DB03273lbxq</tt>}}. Could anyone help writing another dc code to generate that hexadecimal number? I think it will be a good idea to add them, in pair, as an example of string handling in dc which is not yet covered by other examples. [[User:Billyauhk|Billyauhk]] ([[User talk:Billyauhk|talk]]) 08:08, 26 July 2011 (UTC)
 
: : Sorry but I forgotten that we cannot construct a string in dc...but I have just figured out the way to construct the constant: <tt>{{mono|1=(echo -n "0123456789" | xxd -p -u -c 1; echo 0) | dc -"16i0[80?d0!=x*+]dsxx10op"</tt>}} (for Bash...and using GNU dc where != is accepted). For the string "Wikipedia", the constant is: <tt>{{mono|1=30E9C997869D7A6B80</tt>}} [[User:Billyauhk|Billyauhk]] ([[User talk:Billyauhk|talk]]) 10:51, 26 July 2011 (UTC)
::Billyaukh missed the "e" in dc -e "16i0[80?d0!=x*+]dsxx10op" [[User:Annie Yousar|Annie Yousar]] ([[User talk:Annie Yousar|talk]]) 11:46, 2 February 2025 (UTC)