Assuming you are using .Net, you can format the output with;
<%
String format = "<p>{0:#,0 rub .00 kop}</p>";
Response.Write(String.Format(format, 98765.4321));
Response.Write(String.Format(format, 98765.4));
Response.Write(String.Format(format, 987654321));
Response.Write(String.Format(format, 0.12345));
Response.Write(String.Format(format, 0.1));
Response.Write(String.Format(format, 0));
%>
What are the exits;
98,765 rub .43 kop
98,765 rub .40 kop
987,654,321 rub .00 kop
0 rub .12 kop
0 rub .10 kop
0 rub .00 kop
Not sure how to get rid of the decimal point, although omit it if kop == zero.
+/ve -/ve -; http://blog.stevex.net/string-formatting-in-csharp/