Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

numberformat()

Status
Not open for further replies.

timothy

Programmer
Mar 20, 2000
39
US
I am using the numberformat function like so...
#numberformat(variables.totHours,'9,999.0')#
The objective is so .3 shows as 0.3 .

This works find in development but when in production the number comes up like .3 .

I tried another format ___._ with the same results.

Both the hardware and software are the same on development and production.

Any ideas?
Thanks in advance.
 
Wrote this little routine to handle some other formatting issues. Gives you more control over what's going on.

<cfscript>
function FormatDecimal(value, mask)
{
if(len(mask) EQ 0)
{ return value;
}
else
{ if(len(value) EQ 0)
{value = 0;}
k = len(mask);
z = len(value);
right_mask = &quot;&quot;;
left_mask = &quot;&quot;;
found = false;
for(i = k; i GT 0; i = i -1)
{ if(mid(mask, i, 1) EQ &quot;.&quot;)
{ /*skip decimal point*/
found = true;
}
else
{ if(found)
{ left_mask = left_mask & mid(mask, i, 1);
}
else
{ right_mask = right_mask & mid(mask, i, 1);
}
}
}
left_value = value \ 1;
right_value = (value - left_value) * 100000;

k = len(left_mask);
z = len(left_value);
newstr_left = &quot;&quot;;
for(i = k; i GT 0; i = i - 1)
{ switch (mid(left_mask, i, 1))
{ case &quot;9&quot;:
if(z GT 0)
{ newstr_left = mid(left_value, z, 1) & newstr_left;
z = z - 1;
}
break;
default:
newstr_left = mid(left_mask, i, 1) & newstr_left;
break;
}
}

k = len(right_mask) + 1;
z = 1;
newstr_right = &quot;&quot;;
for(i = 1; i LT k; i = i + 1)
{ switch (mid(right_mask, i, 1))
{ case &quot;9&quot;:
if(z GT 0)
{ newstr_right = mid(right_value, z, 1) & newstr_right;
z = z + 1;
}
else
{ newstr_right = &quot;0&quot; & newstr_right;
}
break;
default:
newstr_right = mid(right_mask, i, 1) & newstr_right;
break;
}
}
newstr = newstr_left & &quot;.&quot; & newstr_right;
return newstr;
}
}
</cfscript>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top