Click here to Skip to main content
15,921,156 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: writing a timestamp to a xml file. Pin
malcomhfc12-Oct-09 10:44
malcomhfc12-Oct-09 10:44 
QuestionExport Data to Excel Pin
Puffsss10-Oct-09 23:22
Puffsss10-Oct-09 23:22 
AnswerRe: Export Data to Excel Pin
Andy_L_J10-Oct-09 23:28
Andy_L_J10-Oct-09 23:28 
AnswerRe: Export Data to Excel Pin
The Man from U.N.C.L.E.12-Oct-09 4:18
The Man from U.N.C.L.E.12-Oct-09 4:18 
QuestionNumerical accuracy in calculation Pin
A.Najafi10-Oct-09 21:55
A.Najafi10-Oct-09 21:55 
AnswerRe: Numerical accuracy in calculation Pin
Andy_L_J10-Oct-09 23:11
Andy_L_J10-Oct-09 23:11 
GeneralRe: Numerical accuracy in calculation Pin
A.Najafi11-Oct-09 0:13
A.Najafi11-Oct-09 0:13 
GeneralRe: Numerical accuracy in calculation Pin
Andy_L_J11-Oct-09 0:34
Andy_L_J11-Oct-09 0:34 
I am not Maths Wizard (I was a terrible student), but this excerpt from Wikipaedia on double floating point precision may shed some light...
Why do you need to return so many digits after the decimal point?

Addition and subtraction

A simple method to add floating-point numbers is to first represent them with the same exponent. In the example below, the second number is shifted right by three digits, and we then proceed with the usual addition method:

123456.7 = 1.234567 * 10^5
  101.7654 = 1.017654 * 10^2 = 0.001017654 * 10^5
  
  Hence:
  123456.7 + 101.7654 = (1.234567 * 10^5) + (1.017654 * 10^2)
                      = (1.234567 * 10^5) + (0.001017654 * 10^5)
                      = (1.234567 + 0.001017654) * 10^5
                      =  1.235584654 * 10^5


In detail:

e=5;  s=1.234567     (123456.7)
+ e=2;  s=1.017654     (101.7654)

  e=5;  s=1.234567
+ e=5;  s=0.001017654  (after shifting)
--------------------
  e=5;  s=1.235584654  (true sum: 123558.4654)


This is the true result, the exact sum of the operands. It will be rounded to seven digits and then normalized if necessary. The final result is

e=5;  s=1.235585    (final sum: 123558.5)


Note that the low 3 digits of the second operand (654) are essentially lost. This is round-off error. In extreme cases, the sum of two non-zero numbers may be equal to one of them:

 e=5;  s=1.234567
+ e=-3; s=9.876543

  e=5;  s=1.234567
+ e=5;  s=0.00000009876543 (after shifting)
----------------------
  e=5;  s=1.23456709876543 (true sum)
  e=5;  s=1.234567         (after rounding/normalization)


Another problem of loss of significance occurs when two close numbers are subtracted. In the following example e = 5; s = 1.234571 and e = 5; s = 1.234567 are representations of the rationals 123457.1467 and 123456.659.

e=5;  s=1.234571
- e=5;  s=1.234567
----------------
  e=5;  s=0.000004
  e=-1; s=4.000000 (after rounding/normalization)


The best representation of this difference is e = −1; s = 4.877000, which differs more than 20% from e = −1; s = 4.000000. In extreme cases, the final result may be zero even though an exact calculation may be several million. This cancellation illustrates the danger in assuming that all of the digits of a computed result are meaningful. Dealing with the consequences of these errors is a topic in numerical analysis; see also Accuracy problems.

I don't speak Idiot - please talk slowly and clearly

I don't know what all the fuss is about with America getting it's first black president. Zimbabwe's had one for years and he's sh*t. - Percy Drake , Shrewsbury

Driven to the arms of Heineken by the wife

GeneralRe: Numerical accuracy in calculation Pin
A.Najafi11-Oct-09 1:42
A.Najafi11-Oct-09 1:42 
GeneralRe: Numerical accuracy in calculation Pin
Dave Kreskowiak11-Oct-09 6:57
mveDave Kreskowiak11-Oct-09 6:57 
GeneralRe: Numerical accuracy in calculation Pin
Luc Pattyn11-Oct-09 8:13
sitebuilderLuc Pattyn11-Oct-09 8:13 
Questioninserting input into matlab and run m-file from vb Pin
waiting 4 some110-Oct-09 21:17
waiting 4 some110-Oct-09 21:17 
QuestionHow to add headings to a dataset Pin
Dhruva Hein10-Oct-09 9:27
Dhruva Hein10-Oct-09 9:27 
AnswerRe: How to add headings to a dataset Pin
Henry Minute10-Oct-09 11:18
Henry Minute10-Oct-09 11:18 
GeneralRe: How to add headings to a dataset Pin
Dhruva Hein10-Oct-09 12:49
Dhruva Hein10-Oct-09 12:49 
GeneralRe: How to add headings to a dataset Pin
Henry Minute10-Oct-09 13:38
Henry Minute10-Oct-09 13:38 
GeneralRe: How to add headings to a dataset Pin
Dave Kreskowiak10-Oct-09 16:15
mveDave Kreskowiak10-Oct-09 16:15 
QuestionOpen File with my application Pin
Anubhava Dimri10-Oct-09 0:24
Anubhava Dimri10-Oct-09 0:24 
AnswerRe: Open File with my application Pin
Steven J Jowett10-Oct-09 0:41
Steven J Jowett10-Oct-09 0:41 
QuestionNeed Help Pin
Purish Dwivedi9-Oct-09 22:53
Purish Dwivedi9-Oct-09 22:53 
AnswerRe: Need Help PinPopular
Andy_L_J9-Oct-09 23:03
Andy_L_J9-Oct-09 23:03 
GeneralRe: Need Help Pin
Mycroft Holmes10-Oct-09 1:26
professionalMycroft Holmes10-Oct-09 1:26 
GeneralRe: Need Help Pin
Richard MacCutchan10-Oct-09 2:48
mveRichard MacCutchan10-Oct-09 2:48 
Questionmouse over form border event problem Pin
faith4ever4u9-Oct-09 12:12
faith4ever4u9-Oct-09 12:12 
AnswerRe: mouse over form border event problem Pin
Dave Kreskowiak9-Oct-09 12:20
mveDave Kreskowiak9-Oct-09 12:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.