A guest's language is obscene. What should I do?
Wrong answer
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What can I do?
• What to Read?
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Зарегистрируйся!

QAIX > ASP web-programming > Wrong answer 26 May 2008 12:58:01

  Recent blog posts: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Moderators:

Wrong answer

Old Pedant 26 May 2008 12:58:01
 
"Neil Gould" wrote:

Recently, .nLL <noone@here.com> posted:
<%=2/33334%>
returns 5.99988000239995E-0­5
how can i convert it to a n.nn ?
VBScript:
<%=Round(2/3334, 2)%>

No, that will actually display simply
0

That's because his number, rounded to 2 decimal places, is 0.00 (no non-zero
digits). But *AS A NUMBER*, there is no difference between 0.00 and just
plain 0.

So when you Response.Write zero, you get simply
0
Nothing more.

You *MUST* use
FormatNumber( 2/33334, 2 )
or equivalent if you really want to see
0.00
displayed.
Add comment
Evertjan. 26 May 2008 12:20:43 permanent link ]
 =?Utf-8?B?T2xkIFBlZG­FudA==?= wrote on 26 mei 2008 in
microsoft.public.in­etserver.asp.general­:

"Neil Gould" wrote:
Recently, .nLL <noone@here.com> posted:
<%=2/33334%>
returns 5.99988000239995E-0­5
how can i convert it to a n.nn ?
VBScript:
<%=Round(2/3334, 2)%>
No, that will actually display simply
0
That's because his number, rounded to 2 decimal places, is 0.00 (no
non-zero digits). But *AS A NUMBER*, there is no difference between
0.00 and just plain 0.
So when you Response.Write zero, you get simply
0
Nothing more.
You *MUST* use
FormatNumber( 2/33334, 2 )
or equivalent if you really want to see
0.00
displayed.

You could bake your own,
giving you power over the rounding process:

========= vbs ==============
function myFormatNumber(n,d)­
if n<0 then s = "-" else s = ""
n = fix(abs(n)*10^d + 0.5)
if n=0 then s=""
while len(n)<d+1
n = "0"&n
wend
myFormatNumber = s&left(n,len(n)-d)&­"."&right(n,d)
if d=0 then myFormatNumber = s&n
end function
===================­========









--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Add comment
Evertjan. 26 May 2008 12:58:01 permanent link ]
 Evertjan. wrote on 26 mei 2008 in microsoft.public.in­etserver.asp.general­:

You *MUST* use
FormatNumber( 2/33334, 2 )
or equivalent if you really want to see
0.00
displayed.
You could bake your own,
giving you power over the rounding process:
========= vbs ==============
function myFormatNumber(n,d)­
if n<0 then s = "-" else s = ""
n = fix(abs(n)*10^d + 0.5)
if n=0 then s=""
while len(n)<d+1
n = "0"&n
wend
myFormatNumber = s&left(n,len(n)-d)&­"."&right(n,d)
if d=0 then myFormatNumber = s&n
end function
===================­========

============== jscript ===========
function myFormatNumber(n,d)­{
var s = (n<0)?'-':'';
n = Math.floor(Math.abs­(n)*Math.pow(10,d)+.­5);
if (!n) s='';
if (!d) return s+n;
n += ''; while (n.length<d+1) n = '0' + n;
l = n.length;
return s+n.slice(0,l-d)+'.­'+n.slice(l-d);
};
===================­===============

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или УК РФ.


QAIX > ASP web-programming > Wrong answer 26 May 2008 12:58:01

see also:
Simple example of expiring download…
crc32
Constants in class definitions
пройди тесты:
see also:
Running Stream
Strawberry Cake

  Copyright © 2001—2008 QAIX
Idea: Miсhael Monashev
Помощь и задать вопросы можно в сообществе support.qaix.com.
Сообщения об ошибках оставляем в сообществе bugs.qaix.com.
Предложения и комментарии пишем в сообществе suggest.qaix.com.
Информация для родителей.
Write us at:
If you would like to report an abuse of our service, such as a spam message, please .