473,413 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

A Bug in Math.IEERemainder?

Hi,

When calculating a remainder, R, as a result of X / Y, you wouldn't expect R
to be greater than Y, right? Wrong!

Math.IEEERemainder( double.MaxValue, 1000.0 ) returns 1.99584030953472E+292.
I understand why and how this happens, but the point is that returning a
value that is greater than the divisor, 1000.0, is completely wrong and no
reason could be used as an excuse.

Incidentally, Math.IEEERemainder( double.MaxValue, 100.0 ) returns 0.0 as
expected.

Sunny S
Nov 17 '05 #1
3 1829
Sunny S <su***@neverland.com> wrote:
When calculating a remainder, R, as a result of X / Y, you wouldn't expect R
to be greater than Y, right? Wrong!

Math.IEEERemainder( double.MaxValue, 1000.0 ) returns 1.99584030953472E+292.
I understand why and how this happens, but the point is that returning a
value that is greater than the divisor, 1000.0, is completely wrong and no
reason could be used as an excuse.

Incidentally, Math.IEEERemainder( double.MaxValue, 100.0 ) returns 0.0 as
expected.


This appears to be fixed in .NET 2.0 beta 2 - at least, the above
returns 368, which I believe to be correct.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
Thanks, Jon. 368 is ok At least it looks like a reasonable trade-off between
accuracy and performanceJ

Sunny S.

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Sunny S <su***@neverland.com> wrote:
When calculating a remainder, R, as a result of X / Y, you wouldn't
expect R
to be greater than Y, right? Wrong!

Math.IEEERemainder( double.MaxValue, 1000.0 ) returns
1.99584030953472E+292.
I understand why and how this happens, but the point is that returning a
value that is greater than the divisor, 1000.0, is completely wrong and
no
reason could be used as an excuse.

Incidentally, Math.IEEERemainder( double.MaxValue, 100.0 ) returns 0.0 as
expected.


This appears to be fixed in .NET 2.0 beta 2 - at least, the above
returns 368, which I believe to be correct.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 17 '05 #3
Sunny S <su***@neverland.com> wrote:
Thanks, Jon. 368 is ok At least it looks like a reasonable trade-off between
accuracy and performanceJ


368 is better than okay though - I believe it's the exactly correct
value, given the output of my DoubleConverter which shows the *exact*
value of any double.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #4

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

Similar topics

16
by: Frank Millman | last post by:
Hi all I was helping my niece with her trigonometry homework last night. Her calculator's batteries were flat, so I thought I would use Python's math module to calculate sin, cos, and tan. I...
0
by: Jussi Mononen | last post by:
Hi, I'm having problems to successfully execute the test scripts on a Compaq host ( OSF1 tr51bdev V5.1 2650 alpha ). Almost all tests end up with the following error message "PARI: *** ...
1
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...
17
by: cwdjrxyz | last post by:
Javascript has a very small math function list. However there is no reason that this list can not be extended greatly. Speed is not an issue, unless you nest complicated calculations several levels...
7
by: bravesplace | last post by:
Hello, I am using the folling funtion to round a number to a single digit on my form: function round1(num) { return Math.round(num*1)/1 }
110
by: Gregory Pietsch | last post by:
I'm writing a portable implementation of the C standard library for http://www.clc-wiki.net and I was wondering if someone could check the functions in math.h for sanity/portability/whatever. I'm...
11
by: Sambo | last post by:
I have the following module: ------------------------------- import math def ac_add_a_ph( amp1, ph1, amp2, ph2 ): amp3 = 0.0 ph3 = 0.0 ac1 = ( 0, 0j ) ac2 = ( 0, 0j )
0
by: kirby.urner | last post by:
Cyber-curricula have a leveling aspect, as kids nearer Katrina's epicenter tune in and bliss out on 'Warriors of the Net' (why wait for stupid big dummy textbooks to catch up?). They feel more...
15
by: bH | last post by:
Hi All, I have been looking at javascript drawing from this website : http://www.cwdjr.net/geometricDraw/pentagon_draw.html" and I am wondering why the author made it into two images : upper...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.