Using Math.pow(100000 00,10) or Math.pow(10000* 1000,10) returns:
9.9999999999999 99e+69 (Mozilla 0.8)
1e+70 (Opera 8 & Explorer 6)
Is this a Mozilla bug? Ten million is a power of ten, isn't it? 4 1988
Tony said: Using Math.pow(100000 00,10) or Math.pow(10000* 1000,10) returns:
9.9999999999999 99e+69 (Mozilla 0.8)
1e+70 (Opera 8 & Explorer 6)
Is this a Mozilla bug? Ten million is a power of ten, isn't it?
A bug? Do you realize how small the percentage difference is?
The two values are identical for all practical purposes.
Tony said the following on 9/29/2005 9:25 PM: Using Math.pow(100000 00,10) or Math.pow(10000* 1000,10) returns:
9.9999999999999 99e+69 (Mozilla 0.8)
1e+70 (Opera 8 & Explorer 6)
Is this a Mozilla bug?
No.
Ten million is a power of ten, isn't it?
Yes. But, computers do not do calculations in base 10. They do it in
floating point base 2 math. Convert to base 2, do calculations, convert
back to base 10.
What you are seeing is a difference in implementation, not a bug.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq
Tony wrote: Using Math.pow(100000 00,10) or Math.pow(10000* 1000,10) returns:
9.9999999999999 99e+69 (Mozilla 0.8)
1e+70 (Opera 8 & Explorer 6)
Is this a Mozilla bug? Ten million is a power of ten, isn't it?
Pretty much every number can be expressed as a power of 10, logarithms
wouldn't be very useful otherwise. :-)
You may find this useful:
<URL:http://www.merlyn.demo n.co.uk/js-maths.htm#Float >
--
Rob
JRS: In article <11************ *********@z14g2 000cwz.googlegr oups.com>,
dated Thu, 29 Sep 2005 18:25:19, seen in news:comp.lang. javascript, Tony
<an************ @yahoo.co.uk> posted : Using Math.pow(100000 00,10) or Math.pow(10000* 1000,10) returns:
9.9999999999999 99e+69 (Mozilla 0.8)
1e+70 (Opera 8 & Explorer 6)
Is this a Mozilla bug? Ten million is a power of ten, isn't it?
I can think of three ways of implementing Math.pow(X, N) for integer N :
The method used for Math.pow(X, Y) for non-integer Y
Squaring A and halving N until N=0
Multiplying 1 by A, N times
They are likely to give different rounding errors.
A smart implementer will consider both accuracy and speed in choosing a
method; but not all implementers are smart.
Calculations in which all intermediates and results are integers of
magnitude <= 2^53 should be exact; others should be expected to be
approximated.
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Clueless Moron |
last post by:
Why do they act differently with respect to complex numbers?
Python 2.2.2 (#1, Feb 24 2003, 19:13:11)
on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> pow(2, 0+1j)
(0.76923890136397211+0.63896127631363475j)
>>>
>>> import math
>>> math.pow(2, 0+1j)
|
by: limelight |
last post by:
I have discovered a math error in the .NET framework's Log function. It
returns incorrect results for varying powers of 2 that depend on whether the
program is run from within the IDE or from the command line. The amount by
which the calculation is off is very small; even though the double data type
holds the errant value, it seems to round off when printed (via ToString())
and shows the correct one. The problem is that the errant value is...
|
by: McKirahan |
last post by:
How do I add floating point numbers accurately?
The following adds the 4 numbers
46.57, 45.00, 45.00, and 54.83 to give
191.39999999999998 instead of 191.40.
<html>
<head>
<title>floats.htm</title>
</head>
|
by: David |
last post by:
Here is some code. I am trying to figure out how to raise, say, x to
the yth power. I know that isn't explicitly what is in the code but
that is the idea I am trying to solve. See the 2nd for loop>>3 errors.
#include <stdio.h>
#include <math.h>
int main(void)
{
#define p 100000;
|
by: Darius Fatakia |
last post by:
Hi,
I seem to be having trouble with some of my math functions (pow, sqrt,
acos). They're the only ones I use in my code and they prevent the program
from compiling. I get a "undefined reference to 'pow'" error. Here is the
relevant portion of my code.
Your help would be appreciated. Thanks!
* Genetic Algorithm module
| |
by: a.dheeraj.kumar |
last post by:
i know that there is a function to find the logarithm of a number, sin,
cos, tan etc. but are there which can find sin^-1, cos^-1, tan^-1 and
antilog of a given number?
PS: sin^-1 means sin inverse. eg:
if sin 30 =1/2
30=sin inverse of 1/2
HELP!
|
by: Andy |
last post by:
Hi,
I noticed when migrating a 2002 application to 2003 that the system changed
to a different usage for pow(2,-15).
In 2002, it used double pow(double,double).
In 2003, it is using double pow(int,int).
You may note that pow(2,-15) and pow(2.0,-15.0) give different results.
math.h is included.
Is there some way to force studio to not use the complex prototypes?
math.h is the only include file being used. Why is it even linking to the...
|
by: Nondisclosure007 |
last post by:
Hello. If this is the wrong group for this, please let me know.
I'll
post it somewhere else.
I've been doing data imports into MS Excel (ver 2007) and using the
CORREL function. What I was wondering was is there anything like
this
in Visual Basic or C#? Or even a DLL? I've got VS2008 and I really
don't want to code the CORREL function by hand if I can just pass off
2 or more array's to a function that already exists.
|
by: Tzury Bar Yochay |
last post by:
What is the reason math.pow yields OverflowError while python itself
can
calculate these large numbers. e.g:
1e+308
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: math range error
10000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |