Click here to Skip to main content
15,896,063 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: How to find FINV Pin
Paul Conrad30-Jul-08 6:11
professionalPaul Conrad30-Jul-08 6:11 
GeneralRe: How to find FINV Pin
sumit703430-Jul-08 19:06
sumit703430-Jul-08 19:06 
Generalimplemented the problem Pin
sumit703431-Jul-08 1:47
sumit703431-Jul-08 1:47 
GeneralRe: implemented the problem Pin
Paul Conrad2-Aug-08 10:46
professionalPaul Conrad2-Aug-08 10:46 
GeneralRe: implemented the problem Pin
sumit70344-Aug-08 0:11
sumit70344-Aug-08 0:11 
GeneralRe: implemented the problem Pin
Paul Conrad4-Aug-08 4:57
professionalPaul Conrad4-Aug-08 4:57 
QuestionHow to get a correct string representation of double? Pin
oleg6328-Jul-08 11:28
professionaloleg6328-Jul-08 11:28 
AnswerRe: How to get a correct string representation of double? Pin
Luc Pattyn28-Jul-08 12:27
sitebuilderLuc Pattyn28-Jul-08 12:27 
Hi,

there is simply no solution to your problem. Floating point numbers, by their very nature, cannot always represent the intended value.

The simplest example is the outcome of 1.0/3.0

humans write it down as 0.333333..., computers perform the division in binary and get a reasonably
accurate quotient (say off by no more than 1 of the lowest bit position), which is after all
an approximation.
The binary approximation of 1/3 is something like 1/4 + 1/16 + 1/64 + 1/256 + ...
and it has to stop somewhere since there are only so many bits reserved for the mantissa.

Similar things will happen to almost all real numbers; in order to avoid it, the number must
happen to be an integer value possibly divided by a power of two.

Hence 1.0/4.0, 7.0/4.0, 23.0/256.0 etc can be represented exactly,
whereas numbers with a prime factor (other than 2) in the denominator will not be exact,
nor will irrational numbers (such as pi, or the square root of 2).

If you know how many decimals (i.e. digits behind the decimal point) are required to get an exact
representation, then order that number of decimals or fewer. Rounding will occur, and everything
will look very natural.

If you don't know the number of decimals required and care very much about the correctness of them,
say you start your own financial program or business, then you'd better have a look at the decimal type. It offers a smaller range of numbers, but in some sense a better accuracy.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

Fixturized forever. Confused | :confused:


GeneralRe: How to get a correct string representation of double? Pin
oleg6329-Jul-08 4:24
professionaloleg6329-Jul-08 4:24 
GeneralRe: How to get a correct string representation of double? Pin
CPallini29-Jul-08 7:41
mveCPallini29-Jul-08 7:41 
AnswerRe: How to get a correct string representation of double? Pin
Paul Conrad28-Jul-08 18:19
professionalPaul Conrad28-Jul-08 18:19 
GeneralRe: How to get a correct string representation of double? Pin
ClementsDan31-Jul-08 18:42
ClementsDan31-Jul-08 18:42 
AnswerRe: How to get a correct string representation of double? Pin
cp987628-Jul-08 22:13
cp987628-Jul-08 22:13 
AnswerRe: How to get a correct string representation of double? Pin
prathapcode3-Jun-09 1:19
prathapcode3-Jun-09 1:19 
GeneralRe: How to get a correct string representation of double? Pin
oleg633-Jun-09 4:04
professionaloleg633-Jun-09 4:04 
QuestionC# code for optimal path, given adjacency matrix/cost values? Pin
sherifffruitfly27-Jul-08 7:08
sherifffruitfly27-Jul-08 7:08 
AnswerRe: C# code for optimal path, given adjacency matrix/cost values? Pin
Tim Craig27-Jul-08 20:09
Tim Craig27-Jul-08 20:09 
GeneralRe: C# code for optimal path, given adjacency matrix/cost values? Pin
sherifffruitfly28-Jul-08 5:22
sherifffruitfly28-Jul-08 5:22 
GeneralRe: C# code for optimal path, given adjacency matrix/cost values? Pin
Paul Conrad28-Jul-08 5:49
professionalPaul Conrad28-Jul-08 5:49 
GeneralRe: C# code for optimal path, given adjacency matrix/cost values? Pin
sherifffruitfly28-Jul-08 9:45
sherifffruitfly28-Jul-08 9:45 
GeneralRe: C# code for optimal path, given adjacency matrix/cost values? Pin
Paul Conrad28-Jul-08 9:48
professionalPaul Conrad28-Jul-08 9:48 
GeneralRe: C# code for optimal path, given adjacency matrix/cost values? Pin
sherifffruitfly29-Jul-08 12:51
sherifffruitfly29-Jul-08 12:51 
QuestionCategorisation Pin
Jammer26-Jul-08 5:33
Jammer26-Jul-08 5:33 
AnswerRe: Categorisation Pin
Alan Balkany28-Jul-08 5:21
Alan Balkany28-Jul-08 5:21 
QuestionHow much different are they? Pin
Ian Uy24-Jul-08 3:45
Ian Uy24-Jul-08 3:45 

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.