473,795 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

<%=1/15%> retuns 6.6666666666666 7E-02

yes <%=1/15%retuns 6.6666666666666 7E-02

anyone knows why or where i am wrong?

Jun 25 '07 #1
4 1608
..nLL wrote:
yes <%=1/15%retuns 6.6666666666666 7E-02

anyone knows why or where i am wrong?
Take a look at this series of blog articles about floating point
arithmetic. It starts here:
http://blogs.msdn.com/ericlippert/ar...10/350108.aspx

You can find the rest of the series using the link to the chronological
list of posts on the right side of the page.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jun 25 '07 #2
This is a bit complicated than i expected. is there any function that
will help me to return proper result (like 0.06) from 1/15?

Thank you
On Jun 25, 1:48 pm, "Bob Barrows [MVP]" <reb01...@NOyah oo.SPAMcom>
wrote:
.nLL wrote:
yes <%=1/15%retuns 6.6666666666666 7E-02
anyone knows why or where i am wrong?

Take a look at this series of blog articles about floating point
arithmetic. It starts here:http://blogs.msdn.com/ericlippert/ar...10/350108.aspx

You can find the rest of the series using the link to the chronological
list of posts on the right side of the page.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Jun 25 '07 #3
OK, a simple answer:
No.

The correctly rounded result is 0.07, so if you want the result to be
"0.06", you will need to write complicated code to round the result the
way you want to (why do you want to round down?).

There is no substitute to learning how to properly deal with f-p
arithmetic. This will not be the last time you encounter this.

For a simple answer, try the vbscript FormatNumber function.

..nLL wrote:
This is a bit complicated than i expected. is there any function that
will help me to return proper result (like 0.06) from 1/15?

Thank you
On Jun 25, 1:48 pm, "Bob Barrows [MVP]" <reb01...@NOyah oo.SPAMcom>
wrote:
>.nLL wrote:
>>yes <%=1/15%retuns 6.6666666666666 7E-02
>>anyone knows why or where i am wrong?

Take a look at this series of blog articles about floating point
arithmetic. It starts
here:http://blogs.msdn.com/ericlippert/ar...10/350108.aspx

You can find the rest of the series using the link to the
chronologica l
list of posts on the right side of the page.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get
a
quicker response by posting to the newsgroup.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jun 25 '07 #4
thank you formatnumber was the answer i was looking for
On Jun 25, 2:41 pm, "Bob Barrows [MVP]" <reb01...@NOyah oo.SPAMcom>
wrote:
OK, a simple answer:
No.

The correctly rounded result is 0.07, so if you want the result to be
"0.06", you will need to write complicated code to round the result the
way you want to (why do you want to round down?).

There is no substitute to learning how to properly deal with f-p
arithmetic. This will not be the last time you encounter this.

For a simple answer, try the vbscript FormatNumber function.

.nLL wrote:
This is a bit complicated than i expected. is there any function that
will help me to return proper result (like 0.06) from 1/15?
Thank you
On Jun 25, 1:48 pm, "Bob Barrows [MVP]" <reb01...@NOyah oo.SPAMcom>
wrote:
.nLL wrote:
yes <%=1/15%retuns 6.6666666666666 7E-02
>anyone knows why or where i am wrong?
Take a look at this series of blog articles about floating point
arithmetic. It starts
here:http://blogs.msdn.com/ericlippert/ar...10/350108.aspx
You can find the rest of the series using the link to the
chronological
list of posts on the right side of the page.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get
a
quicker response by posting to the newsgroup.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Jun 25 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3232
by: Eshrath | last post by:
Hi, What I am trying to do: ======================= I need to form a table in html using the xsl but the table that is formed is quite long and cannot be viewed in our application. So we are writing one object in C# which will take the entire table tag contents and renders. Ie., we need to pass "<table>………… <thead>……</thead>. <tr>.<td> <td>..<tr>.<td> <td> </table>" content to
2
10569
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script type="text/javascript"> <!]> </script> <script type="text/javascript"
1
3175
by: Mike Strieder | last post by:
How can i get the text of the System.Type e.g. "base64Binary" from the .Net type "byte" I can not found any Function to give back this Schematype as string. thx for your help
2
15953
by: ESPNSTI | last post by:
Hi, I'm trying to use a generics dictionary with a key class that implements and needs IComparable<>. However when I attempt to use the dictionary, it doesn't appear to use the IComparable<> to find the key. In the example below, accessing the dictionary by using the exact key object that was used to add to the dictionary works. (see code comment 1). However, if I attempt to access the dictionary by using a key object that
9
3688
by: Simple Simon | last post by:
Java longs are 8 bytes. I have a Java long that is coming in from the network, and that represents milliseconds since Epoch (Jan 1 1970 00:00:00). I'm having trouble understanding how to get it into a struct timeval object. I get the ByteBuffer as an array of const unsigned char, 'buffer'. Here's an example: 00 00 01 0A 29 1D 07 E4 This value maps somehow to Thu Mar 23 16:57:49 2006 and some
3
3384
by: ajay2552 | last post by:
Hi, I have a query. All html tags start with < and end with >. Suppose i want to display either '<' or '>' or say some text like '<Company>' in html how do i do it? One method is to use &lt, &gt ,&ltCompany&gt to display '<', '>' and '<Company>' respectively. But is there any freeware code available which could implement the above functionality without having to use &gt,&lt and such stuff???
45
18908
by: Zytan | last post by:
This returns the following error: "Cannot modify the return value of 'System.Collections.Generic.List<MyStruct>.this' because it is not a variable" and I have no idea why! Do lists return copies of their elements? Why can't I change the element itself? class Program { private struct MyStruct
14
3162
by: Michael | last post by:
Since the include function is called from within a PHP script, why does the included file have to identify itself as a PHP again by enclosing its code in <?php... <?> One would assume that the PHP interpreter works like any other, that is, it first expands all the include files, and then parses the resulting text. Can anyone help with an explanation? Thanks, M. McDonnell
2
2059
by: -Karl | last post by:
Couls someone please advise me on this error. What I am trying to do is be able to convert an XML document into arrays. I read that the subs & functions have to be in <scripttags. Thanks! Error: BC30456: 'Read_DOM' is not a member of
8
4025
by: michael | last post by:
Hi all A client of mine is having a problem with their site and when I looked into the SQL database, I found that most text fields have been altered and appended with script src=http://www.westpacsecuresite.com/b.js/script I've taken out the < so that this shows.
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10214
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10164
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7540
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.