Thursday, December 23, 2004

Number rounding in JavaScript
So trivial a task to us humans, almost so to JavaScript as well. Round up your brain cells as we explore number rounding in the language!
Basic idea
JavaScript helps lay the foundation for rounding off numbers with the following method:
Using it, any supplied argument is rounded off to the nearest integer, and using the ".5" up rule. For example:
Math.round(25.9) //returns 26Math.round(25.2) //returns 25Math.round(-2.58) //returns -3
If purging numbers of decimals is all that you require, class dismissed!
Taking things a few decimals further
Want to display $25 in standard currency format? How about PI to finity and not beyond? Formatting numbers to specific decimal points entails still Math.round(), but padded with a little multiplication and division. See if you can identify the magic formula involved, with the below examples:
var original=28.453
1) //round "original" to two decimalsvar result=Math.round(original*100)/100 //returns 28.45
2) // round "original" to 1 decimalvar result=Math.round(original*10)/10 //returns 28.5
3) //round 8.111111 to 3 decimalsvar result=Math.round(8.111111*1000)/1000 //returns 8.111
In case you haven't picked up on it, the formula to round any number to x decimal points is:
1) Multiple the original number by 10^x (10 to the power of x)2) Apply Math.round() to the result3) Divide result by 10^x

Thursday, August 19, 2004

reduce the size of the log files in sql server2000
in the query analyser run
DBCC SHRINKFILE(SSPLM1_log, 2) here SSPLM1_log is the name of the log file while 2 is the intended size of the file after running the same.

to delete the unnecessary logs then

Thursday, June 24, 2004

SET QUOTED_IDENTIFIER must be ON when creating or manipulating indexes on computed columns or indexed views. If SET QUOTED_IDENTIFIER is OFF, CREATE, UPDATE, INSERT, and DELETE statements on tables with indexes on computed columns or indexed views will fail.

Wednesday, June 23, 2004

its located at oracle\ora81\network\ADMIN

tnsnames.ora is the file where oracle SID is placed

Tuesday, May 11, 2004

To hide a column in a table

below is the code.

content=new Array()
function toggle(theChk) {
tb = document.getElementById("tb1");
id = theChk.value;
for (i=0;i<tb.rows.length;i++) {
for (j=0;j<tb.rows[i].cells.length;j++) {
if (tb.rows[i].cells[j].id.indexOf("col"+id)==0) {

if (chk) tb.rows[i].cells[j].innerHTML=content[tb.rows[i].cells[j].id]
else {
<input type="checkbox" onClick="toggle(this)" value="A" checked>
<input type="checkbox" onClick="toggle(this)" value="B" checked>
<input type="checkbox" onClick="toggle(this)" value="C" checked>
<table id="tb1">
<td id="colAcell0">ColA cell 0</td>
<td id="colBcell0">ColB cell 0</td>
<td id="colCcell0">ColC cell 0</td>
<td id="colAcell1">ColA cell 1</td>
<td id="colBcell1">ColB cell 1</td>
<td id="colCcell1">ColC cell 1</td>
<td id="colAcell2">ColA cell 2</td>
<td id="colBcell2">ColB cell 2</td>
<td id="colCcell2">ColC cell 2</td>

Tuesday, April 27, 2004

My Answer History on EE

Wednesday, March 31, 2004

Javascript function to trim spaces

function trim(s) {
while (s.substring(0,1) == ' ') {
s = s.substring(1,s.length);
while (s.substring(s.length-1,s.length) == ' ') {
s = s.substring(0,s.length-1);
return s;

Saturday, February 28, 2004

Do not pray for easy lives. Pray to be stronger men!

Do not pray for tasks equal to your powers. Pray for power equal to your tasks.

Try a new thing every day.

Friday, February 20, 2004

my books

Thursday, January 29, 2004

"When an actress saw her first strands of gray hair she thought she'd dye."

Web Hosting Cheap PHP Plans Also at For free flags of the world