Strange constants

I saw them in real code:

#define SCREEN_DIMENSIONS 2 #define THREE_THOUSAND_FIVE_HUNDRED_TWENTY_TWO 3522 

What is the strangest constant you've ever seen?

PS And, of course, my favorite in JScript:

 bool b; switch (b.ToString().length) { case 4: // true ... break; case 5: // false ... break; ) 
+41
constants
Feb 06 '09 at 21:38
source share
26 answers

The Android Accelerometer API has gravitational constants for different planets.

http://code.google.com/android/reference/android/hardware/SensorManager.html

+43
Feb 06 '09 at 21:45
source share
— -
 #define NUMBER_OF_CONSTANTS_NOT_INCLUDING_THIS_ONE 4 #define NUMBER_OF_CONSTANTS_INCLUDING_THE_LAST_ONE_BUT_NOT_THIS_ONE 5 
+31
Feb 06 '09 at 22:15
source share
 #define TEN 9 
+26
Feb 06 '09 at 21:41
source share
 #define private public 
+25
Feb 06 '09 at 21:39
source share
 char *myGodItsFullOfStars = "********************************************************************************"; 
+25
Feb 06 '09 at 21:43
source share

To match Indiana HB 246 :

 #ifdef INDIANA const float PI = 3.2; #endif 
+16
Feb 06 '09 at 21:56
source share
 //Thank you Crash Macro!!! #define CRASH (*((void*) 0))++ 

I really used this project in a project where I was engaged in programming using a simulator that did not have a debugger. It happened something like this:

 if(v == SOMETHING_WRONG) CRASH; 

Then I had to spend several hours looking at memory dumps in a hex editor to find out what happened. (also a comment was required).

+14
Feb 06 '09 at 23:02
source share
 #define TRUE 0 #define FALSE 1 
+13
Feb 06 '09 at 21:41
source share

We complained to another programmer that he has too many “magic numbers” in his code and that he must turn them into constants. We must have more specific ...

 Private Const MAGIC_NUMBER as Integer = 7; 
+13
Feb 06 '09 at 23:34
source share

Not a constant, but related to your measurements = 2 remark: when I was in UW, the man page for the print spooler had something like:

 --duplex n Print on this many sides of the page. Acceptable values (until we obtain more versatile printers) are 1 and 2. 
+13
Jun 26 '09 at 22:51
source share

Not the same thing, but I was working on a code base where the variables and labels named after the streets and pubs in Glasgow. So you can write code like

 Goto :TheBowserBar 

The code layout made sense only if you knew the city very well - strange.

+10
Feb 06 '09 at 21:42
source share

From The Daily WTF :

 private String paula = "Brillant"; 
+8
Feb 06 '09 at 21:46
source share

From the first days of C:

 #define PI 3.14159 /* should the value of PI ever change */ 

Yes, I know that they had in mind a constant, but I wonder what kind of extreme behavior a change in the universe must occur to change the actual value of PI.

+7
Feb 06 '09 at 23:24
source share

Here is my personal favorite TDWTF form: pascal.h

 #define procedure void #define then #define is #define not != #define begin { #define end } 
+7
Jun 26 '09 at 10:50
source share

I'm not sure if this counts, but

 #define COMMA , 

I do not remember the specifics, but it was necessary to insert the template arguments.

+6
Feb 12 '09 at 16:04
source share
 public bool bTrue = true; 
+6
Dec 09 '09 at 14:12
source share

Here is a good one that I remember from my last job. He included the following comments.

 'Hard coded to be more dynamic Const DYNAMIC_VAL = 1 
+6
Jul 12 '10 at 14:13
source share

This is an application that uses LOT with ton / lbs conversions:

 const ONE_TON_IN_LBS = 1999.6 
+3
Feb 12 '09 at 15:54
source share

From DailyWTF

 #define whilst while 

Personally in Authorware (which allowed spaces in variable names)

 booBoolMoveOnIsOn True := 1 
+3
Feb 12 '09 at 15:59
source share
 /** SUBVERSION REVISION OF THE FILE */ private String SVN_REVISION = 34234; 

I still do not understand this. It was littered with dozens of files and was never used.

+2
Feb 06 '09 at 21:57
source share

I have never seen, but really want:

 #define MAGIC "more magic" 

We have a bunch of magical #defines here that we use as the core of license keys ...

+1
Feb 06 '09 at 22:05
source share

I once worked on the school board as a COBOL reporting programmer. To comply with the desegregation guidelines, it was necessary to track attendance and race participation. As a result, many of the reports contained student counts in the categories White, Black, Latin American, Asian, Native American, etc.

For some reason, I thought it would be fun to globally change all category names to their ... say, slang equivalents? ... and then ask the boss to help out with some sort of help by debugging the counter overflow problem. Discretization prevents me from recording what the actual names are, but you get a drift.

Took it a couple of minutes to notice. His reaction was funny as hell. Damn, nearby, I got fired, though.

+1
Jun 17 2018-10-06T00:
source share
 #define ADMIN "Admin" 
0
Feb 06 '09 at 22:29
source share

which look like this:

 void FAR PASCAL function()... 

Where:

 #define FAR far #define PASCAL __stdcall 
0
Feb 06 '09 at 23:36
source share

Here is one right from our community.

 #define TRUE 0 #define FALSE 1 

Is there (TRUE) a good idea in C?

0
Feb 12 '09 at 15:49
source share
  #define WTF "What the ...?" 
-one
Jun 26 '09 at 22:41
source share



All Articles