473,466 Members | 1,394 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

remainders of large floating point numbers

Hi Lazyweb,

This is probably something I should have remembered from college.
On 'calc.exe'

( ( 10^15 - 0.1 ) % 2) = 1.9
In C#

double result = 1E+15;
result -= 0.1;
result % 2.0
The result is 1.875

Why does this occur?


Secondly,

Why do numbers bigger than 10^15 when 0.1 is subtracted then modulus 2
always return zero? The same when using IEEERemainder ?

Thanks,

Gary

Oct 24 '07 #1
1 1081
On Oct 24, 6:39 pm, garazy <gbre...@gmail.comwrote:
Hi Lazyweb,

This is probably something I should have remembered from college.

On 'calc.exe'

( ( 10^15 - 0.1 ) % 2) = 1.9

In C#

double result = 1E+15;
result -= 0.1;
result % 2.0

The result is 1.875

Why does this occur?

Secondly,

Why do numbers bigger than 10^15 when 0.1 is subtracted then modulus 2
always return zero? The same when using IEEERemainder ?

Thanks,

Gary

It appears I've already half answered it

http://en.wikipedia.org/wiki/Floatin...uracy_problems
Oct 24 '07 #2

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

Similar topics

18
by: Zero | last post by:
Hi, I am calculating an integer to the pwer of a large integer, e.g. 2^5000. It turns out that the result I always get is zero. I am sure that the result is too large to store in such type...
687
by: cody | last post by:
no this is no trollposting and please don't get it wrong but iam very curious why people still use C instead of other languages especially C++. i heard people say C++ is slower than C but i can't...
10
by: Shawn | last post by:
Hello all, I apologize as I am sure this has probably been dealth with before... but I am doing an exercise from "Practical C Programming" and I have been unable to get it to work perfectly due to...
7
by: Vinoth | last post by:
I'm working in an ARM (ARM9) system which does not have Floating point co-processor or Floating point libraries. But it does support long long int (64 bits). Can you provide some link that would...
15
by: michael.mcgarry | last post by:
Hi, I have a question about floating point precision in C. What is the minimum distinguishable difference between 2 floating point numbers? Does this differ for various computers? Is this...
1
by: Joshco | last post by:
Does anybody know how to force visual to use a number this is around 1000 digits long and 64 bit floating point. I am a beginner in programing.
32
by: ma740988 | last post by:
template <class T> inline bool isEqual( const T& a, const T& b, const T epsilon = std::numeric_limits<T>::epsilon() ) { const T diff = a - b; return ( diff <= epsilon ) && ( diff >= -epsilon );...
2
by: Pete Davis | last post by:
I'm interested in writing some chem/biochem related tools for myself, but it appears the Decimal format isn't going to quite cut it for some of the numbers I'm going to be working with. It's max of...
11
by: Peter | last post by:
I have written this small app to explain an issue I'm having with a larger program. In the following code I'm taking 10 ints from the keyboard. In the call to average() these 10 ints are then...
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
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
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...
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...
1
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...
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
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.