SanskritNumbers.fsp - Frink Server Pages highlighter
[Try SanskritNumbers.fsp]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML LANG="en">
<HEAD>
<TITLE>Sanskrit Number Converter</TITLE>
<META HTTP-EQUIV="Default-Style" CONTENT="APE Airy">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<LINK REL="StyleSheet" HREF="/frinkdocs/apeairy.css" TYPE="text/css"
TITLE="APE Airy">
<LINK REL="Alternate StyleSheet" HREF="/frinkdocs/spaceship.css"
TYPE="text/css" TITLE="Spaceship">
<LINK REL="Alternate StyleSheet" HREF="/frinkdocs/style.css" TYPE="text/css"
TITLE="APE Classic">
<LINK REL="Alternate StyleSheet" HREF="/frinkdocs/style2.css" TYPE="text/css"
TITLE="Compact">
<LINK REL="icon" HREF="/images/futureboyicon.png" TYPE="image/png">
<META NAME="viewport" CONTENT="width=device-width, initial-scale=1.0">
</HEAD>
<BODY onLoad="ans.focus()">
<% use ../IndianAstronomy.frink %>
<H1>Sanskrit Number Converter</H1>
<A NAME="S2D"><H2>Sanskrit to Decimal</H2></A>
<P>
Enter Sanskrit numbers in the form १४।१२।१३ using the buttons below or in the Neugebauer form
(e.g. 14;12,13).
</P>
<%
if n
{
dev = numberToDevanagari[n]
neu = DevanagariToNeugebauer[dev]
equiv = parseDevanagariFraction[dev]
ne = equiv div 1
fe = equiv - ne
dequiv = 1.0 equiv
println["<DIV CLASS=\"back\">"]
println["""<P>
<SPAN STYLE="font-size:x-large">$dev
<BR>$neu
</SPAN>
</P>"""]
if (fe != 0)
println["""<P><SPAN STYLE="font-size:large"> = $ne
+ $fe
</SPAN></P>"""]
println["""<P><SPAN STYLE="font-size:large"> = $dequiv
</SPAN></P>"""]
println["""<P><SPAN STYLE="font-size:large"> = $equiv
</SPAN></P>"""]
println["</DIV>"]
}
%>
<FORM METHOD="POST" ACTION="SanskritNumbers.fsp#S2D">
<P>
Number:<BR>
<INPUT TYPE="TEXT" NAME="n" ID="n"><BR>
<INPUT TYPE="BUTTON" VALUE="० : 0" onClick="inf.value=inf.value+'\u0966
'">
<INPUT TYPE="BUTTON" VALUE="१ : 1" onClick="inf.value=inf.value+'\u0967
'">
<INPUT TYPE="BUTTON" VALUE="२ : 2" onClick="inf.value=inf.value+'\u0968
'">
<INPUT TYPE="BUTTON" VALUE="३ : 3" onClick="inf.value=inf.value+'\u0969
'">
<INPUT TYPE="BUTTON" VALUE="४ : 4" onClick="inf.value=inf.value+'\u096a
'">
<INPUT TYPE="BUTTON" VALUE="५ : 5" onClick="inf.value=inf.value+'\u096b
'">
<INPUT TYPE="BUTTON" VALUE="६ : 6" onClick="inf.value=inf.value+'\u096c
'">
<INPUT TYPE="BUTTON" VALUE="७ : 7" onClick="inf.value=inf.value+'\u096d
'">
<INPUT TYPE="BUTTON" VALUE="८ : 8" onClick="inf.value=inf.value+'\u096e
'">
<INPUT TYPE="BUTTON" VALUE="९ : 9" onClick="inf.value=inf.value+'\u096f
'">
<INPUT TYPE="BUTTON" VALUE="।" onClick="inf.value=inf.value+'\u0964
'">
<BR>
<INPUT TYPE="SUBMIT" VALUE="Convert">
</P>
</FORM>
<A NAME="D2S"><H2>Decimal to Sanskrit</H2></A>
<P>
Enter a decimal number or fraction in the form 1.234, or 1/45, 1+1/2, or
(equivalently,) 1 1/2. In fact, since this is powered by <A HREF="/frinkdocs/">Frink</A>, you can enter any
mathematical expression including dimensionless constants like "pi" or "e".
</P>
<% if digits
{
td = trim[digits]
if td =~ %r/\d+/
digits = parseInt[td]
else
digits = 8
} else
digits = 8
if dec
{
dec =~ %s/(\d+)\s+(\d+)/$1+$2/
num = eval[dec]
nstr = sexagesimal[num, digits]
dstr = numberToDevanagari[nstr]
reconv = parseDevanagariFraction[dstr]
err = abs[num - reconv]
println["<DIV CLASS=\"back\">"]
println["""<P><SPAN STYLE="font-size:large">$dec
=</SPAN></P>
<P><SPAN STYLE="font-size:x-large"> $nstr
</SPAN> (Neugebauer form)<BR>
<SPAN STYLE="font-size:x-large"> $dstr
</SPAN> (Devanagari form)</P>"""]
if (err == 0)
println["<P>(result is exact.)</P>"]
else
println["<P>Error = $err
due to truncation to $digits
digits.</P>"]
println["</DIV>"]
}
%>
<FORM METHOD="POST" ACTION="SanskritNumbers.fsp#D2S" NAME="f2">
<P>
Number: <INPUT TYPE="TEXT" NAME="dec" ID="dec">
Max. sexagesimal digits: <INPUT TYPE="TEXT" NAME="digits" SIZE="2" VALUE="$digits
"><BR>
<INPUT TYPE="SUBMIT" VALUE="Convert">
</P>
</FORM>
<SCRIPT TYPE="text/javascript">
var ans = document.getElementById("<%= dec ? "dec" : "n" %>
");
var inf = document.getElementById("n");
ans.focus();
</SCRIPT>
<HR>
<P>
<I>Comments or questions to <A HREF="mailto:eliasen@mindspring.com">Alan Eliasen</A></I>.
</P>
<P>
<A HREF="highlight.fsp?f=SanskritNumbers.fsp">View Source</A>
</P>
<P>
Back to <A HREF="/frinkdocs/fspdocs.html">Frink Server Pages
documentation.</A>
</P>
</BODY>
</HTML>
[Try SanskritNumbers.fsp]
Alan Eliasen was born
20218 days, 6 hours, 57 minutes ago.
Back to Frink Server Pages
documentation.