Click here to Skip to main content
15,906,766 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: When is a double a string Pin
Luc Pattyn17-May-10 16:44
sitebuilderLuc Pattyn17-May-10 16:44 
GeneralRe: When is a double a string Pin
Chris Losinger18-May-10 1:01
professionalChris Losinger18-May-10 1:01 
GeneralRe: When is a double a string Pin
supercat918-May-10 6:14
supercat918-May-10 6:14 
GeneralRe: When is a double a string Pin
David Skelly13-May-10 4:47
David Skelly13-May-10 4:47 
GeneralRe: When is a double a string Pin
Luc Pattyn13-May-10 4:50
sitebuilderLuc Pattyn13-May-10 4:50 
GeneralRe: When is a double a string Pin
J4amieC13-May-10 5:29
J4amieC13-May-10 5:29 
GeneralRe: When is a double a string Pin
Luc Pattyn13-May-10 5:33
sitebuilderLuc Pattyn13-May-10 5:33 
GeneralRe: When is a double a string Pin
Electron Shepherd13-May-10 6:59
Electron Shepherd13-May-10 6:59 
Luc Pattyn wrote:
where epsilon would be a small positive constant, say 1.0E-15


You can't reliably use a constant for comparisons. The value of epsilon has to be related to the magnitude of the numbers involved. For example (VC++ 6 compiler for reference)

double d1 = 1e299;
double d2 = 1e299 - 1;

double diff = d1 - d2;


gives a result with diff being zero, not one.

double d1 = 1e10;
double d2 = 1e10 - 1;

double diff = d1 - d;


gives a result with diff being 1, as expected.

Basically, epsilion has to be larger than the minimum precision of the double data type given the values contained in it, and the precision, as an absolute, varies with the values.

GeneralRe: When is a double a string Pin
Luc Pattyn13-May-10 7:35
sitebuilderLuc Pattyn13-May-10 7:35 
GeneralRe: When is a double a string Pin
Electron Shepherd13-May-10 7:41
Electron Shepherd13-May-10 7:41 
GeneralRe: When is a double a string Pin
supercat914-May-10 6:36
supercat914-May-10 6:36 
GeneralRe: When is a double a string Pin
PIEBALDconsult13-May-10 4:39
mvePIEBALDconsult13-May-10 4:39 
GeneralRe: When is a double a string Pin
Chris Maunder13-May-10 15:50
cofounderChris Maunder13-May-10 15:50 
GeneralSelecting all coordinates withing a distance Pin
Jeroen De Dauw12-May-10 12:51
Jeroen De Dauw12-May-10 12:51 
QuestionRe: Selecting all coordinates withing a distance Pin
Chris Meech13-May-10 3:09
Chris Meech13-May-10 3:09 
AnswerRe: Selecting all coordinates withing a distance Pin
Jeroen De Dauw13-May-10 3:12
Jeroen De Dauw13-May-10 3:12 
AnswerRe: Selecting all coordinates withing a distance Pin
elchupathingy13-May-10 3:54
elchupathingy13-May-10 3:54 
GeneralRe: Selecting all coordinates withing a distance Pin
Chris Meech13-May-10 4:22
Chris Meech13-May-10 4:22 
GeneralRe: Selecting all coordinates withing a distance Pin
David Skelly13-May-10 4:37
David Skelly13-May-10 4:37 
GeneralRe: Selecting all coordinates withing a distance Pin
Jeremy Hutchinson18-May-10 5:17
professionalJeremy Hutchinson18-May-10 5:17 
AnswerRe: Selecting all coordinates withing a distance Pin
Bernhard Hiller13-May-10 23:10
Bernhard Hiller13-May-10 23:10 
GeneralRe: Selecting all coordinates withing a distance Pin
Bernhard Hiller13-May-10 23:28
Bernhard Hiller13-May-10 23:28 
GeneralRe: Selecting all coordinates withing a distance Pin
Member 35753717-May-10 11:40
Member 35753717-May-10 11:40 
GeneralHow to sequence a loop Pin
TheNexpert6-May-10 23:10
TheNexpert6-May-10 23:10 
GeneralRe: How to sequence a loop Pin
riced6-May-10 23:51
riced6-May-10 23:51 

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.