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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

formatting to #.## 2

Status
Not open for further replies.

WhiteTiger

Programmer
Jun 26, 2001
605
US
What's a quick way for formatting output of a number? Regards,
Anth:cool:ny
----------------------------------------
"You say [red]insanity[/red] like it's a BAD THING!"
 
Please explain with a little more detail. I'm having problems understanding what you require.
 
I want to format 25467.577345 or whatever number TO...#.## format.........not hard to understand really...

25467.57 would be the result... Regards,
Anth:cool:ny
----------------------------------------
"You say [red]insanity[/red] like it's a BAD THING!"
 
Javascript...but of course none of you know how...I've had this thread up for 4 days now. Regards,
Anth:cool:ny
----------------------------------------
"You say [red]insanity[/red] like it's a BAD THING!"
 
No offense, but your question was vague at best, and I have left a question for you to answer for clarification for two days.

Help us to help you, huh? Dean Owen
 
Not quite...asking to format #.##, isn't really vague...

5.34 is #.## format, 5.356 would be #.### format...

plus, before you posted, I provided an example...asking to convert a number similar to 23556.235662 to
23556.23 Hmmmm...grumpy are we? Regards,
Anth:cool:ny
----------------------------------------
"You say [red]insanity[/red] like it's a BAD THING!"
 
Not quite...asking to format #.##, isn't really vague...

5.34 is #.## format, 5.356 would be #.### format...

plus, before you posted, I provided an example...asking to convert a number similar to 23556.235662 to
23556.23 Hmmmm...grumpy are we?...oh, but thanks still...;) Regards,
Anth:cool:ny
----------------------------------------
"You say [red]insanity[/red] like it's a BAD THING!"
 
Stupid forum...you can't edit a post, you can't delete your own post, you can't do anything...sheesh...if you want to change something you said before anyone sees it you cant! Regards,
Anth:cool:ny
----------------------------------------
"You say [red]insanity[/red] like it's a BAD THING!"
 
lol yeah I've done that. Big string of identical posts...

The vague part was - 'What are you using?'

You didn't tell us it was JavaScript until your post where you gave up on us. Not fair! :) Dean Owen
 
I agree with QD, you have to be very clear when you post a question, we are not mind readers. I had to read 5-6 posts to get to the language you were looking for.

Use the PREVIEW POST option and re-read you post before you submit it. We have no idea what project you are working on, what software you are using (Cold Fusion, FrontPage, etc.), or what language the output is being generated from (PHP, CGI, JavaScript, etc.).

Plus you posted in a forum geared torards CSS/DHMTL and expect us to guess you had a JavaScript question.

So yes, you were vague, then you were rude. Luckily we are very cool people that forgive easily.

Either way, here is your script:
Code:
<SCRIPT LANGUAGE='JavaScript'>
<!--

x = 23556.235662;

x = x * 100;
x = Math.round(x);
x = x / 100;

document.write(x);

// -->
</SCRIPT>

Mike Barone
FREE CGI/Perl Scripts & JavaScript Generators
Ace PopUp Generator Software - Totally FREE
 
heh, well, I submitted, then wanted to change it...lol...sorry about being rude yesterday, I was VERY sleepy...I get up at 6:30 in the morning and dont go to bed 'till 1:00 in the morning a lot of the time...yesterday I went home 3 hours early and went straight to bed...sorry again for yesterday. Regards,
Anth:cool:ny
----------------------------------------
&quot;You say [red]insanity[/red] like it's a BAD THING!&quot;
 
And may I say THANK YOU THANK YOU...and I will give out stars after this post...hehe...=)

thanks, it works like a charm...I think I'll make a lil javascript that you can say

formatit(variable, 3) to format it to say have 3 numbers after the .

just to make things a lil more simple. Regards,
Anth:cool:ny
----------------------------------------
&quot;You say [red]insanity[/red] like it's a BAD THING!&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top