Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Operations of FormatNumber function

Reply
 
Old 10-23-2008   #1 (permalink)
Andrew Falanga


 
 

Operations of FormatNumber function

Hi,

I'm wondering about the FormatNumber function (http://
msdn.microsoft.com/en-us/library/ws343esk(VS.85).aspx). If I call
this function with the appropriate arguments to return me a number
with only one figure after the decimal point, is this value rounded or
simply truncated? That is, given the call as described and the math
comes to 1.27, will I be returned 1.2 or 1.3?

Thanks,
Andy

My System SpecsSystem Spec
Old 10-23-2008   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: Operations of FormatNumber function


"Andrew Falanga" <af300wsm@xxxxxx> wrote in message
news:545e7f79-20d4-4a87-9410-2dc1ec98c609@xxxxxx
Quote:

> Hi,
>
> I'm wondering about the FormatNumber function (http://
> msdn.microsoft.com/en-us/library/ws343esk(VS.85).aspx). If I call
> this function with the appropriate arguments to return me a number
> with only one figure after the decimal point, is this value rounded or
> simply truncated? That is, given the call as described and the math
> comes to 1.27, will I be returned 1.2 or 1.3?
>
> Thanks,
> Andy
It rounds, so you should get 1.3.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 10-23-2008   #3 (permalink)
Dr J R Stockton


 
 

Re: Operations of FormatNumber function

In microsoft.public.scripting.vbscript message <545e7f79-20d4-4a87-9410-
2dc1ec98c609@xxxxxx>, Thu, 23 Oct 2008 10:35:47,
Andrew Falanga <af300wsm@xxxxxx> posted:
Quote:

>
>I'm wondering about the FormatNumber function (http://
>msdn.microsoft.com/en-us/library/ws343esk(VS.85).aspx). If I call
>this function with the appropriate arguments to return me a number
>with only one figure after the decimal point, is this value rounded or
>simply truncated? That is, given the call as described and the math
>comes to 1.27, will I be returned 1.2 or 1.3?
A one-line VBS would tell you that.

document.write formatNumber(1.27,1) ' writes 1.3 for me.

--
(c) John Stockton, nr London UK. ??@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
In MS OE, choose Tools, Options, Send; select Plain Text for News and E-mail.
Don't quote more than is needed, and respond after each quoted part.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Type mismatch: FormatNumber VB Script
Authorizing Powershell Operations PowerShell
File operations Vista General
BUG: Redirecting function contents to a file truncates function lines at the width of the console PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46