constants


Weird constants [closed]


I've seen these in real code:
#define SCREEN_DIMENSIONS 2
#define THREE_THOUSAND_FIVE_HUNDRED_TWENTY_TWO 3522
What is the weirdest constant you've ever seen?
P.S. And of course my favorite in JScript:
bool b;
switch (b.ToString().length) {
case 4: // true
...
break;
case 5: // false
...
break;
)
The Android's accelerometer API has gravitational constants for different planets.
http://code.google.com/android/reference/android/hardware/SensorManager.html
#define NUMBER_OF_CONSTANTS_NOT_INCLUDING_THIS_ONE 4
#define NUMBER_OF_CONSTANTS_INCLUDING_THE_LAST_ONE_BUT_NOT_THIS_ONE 5
#define TEN 9
#define private public
char *myGodItsFullOfStars = "********************************************************************************";
To comply with Indiana H.B. 246:
#ifdef INDIANA
const float PI = 3.2;
#endif
//Thank you Crash Macro!!!
#define CRASH (*((void*) 0))++
I actually used that one in a project where i was doing some programming with a simulator that had no debugger. It went something like this:
if(v == SOMETHING_WRONG)
CRASH;
Then I got to spend a few hours looking at memory dumps in a hex editor to find out what happened. (also the comment was obligatory).
#define TRUE 0
#define FALSE 1
Not a constant, but related to your dimensions=2 remark: When I was at UW, the manpage 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.
We complained to another programmer about him having too many "magic numbers" in his code and that he should turn them into constants. We should have more specific...
Private Const MAGIC_NUMBER as Integer = 7;
Not the same, but I worked on a code base where the variables and labels where named after streets and pubs in Glasgow. So you could write code like
Goto :TheBowserBar
The code layout only made sense if you knew the city really well - strange.
From The Daily WTF:
private String paula = "Brillant";
From the early days of C:
#define PI 3.14159 /* should the value of PI ever change */
Yes, I know they meant the constant, but I wonder what sort of extreme universe-altering behavior would have to occur for the actual value of PI to change.
Here's my personal favorite form TDWTF: pascal.h
#define procedure void
#define then
#define is
#define not !=
#define begin {
#define end }
I'm not sure if this counts, but
#define COMMA ,
I can't remember the specifics, but this was necessary for nesting template arguments.
public bool bTrue = true;
Here is a good one I remember from my last job. It included the following comments.
'Hard coded to be more dynamic
Const DYNAMIC_VAL = 1
This in an application that deals a LOT with ton / lbs conversions:
const ONE_TON_IN_LBS = 1999.6
From the DailyWTF
#define whilst while
Personally, in Authorware (which allowed spaces in variables names)
booBoolMoveOnIsOn True := 1
/** SUBVERSION REVISION OF THE FILE */
private String SVN_REVISION = 34234;
I still haven't figured it out. It was littered in a few dozen files, and never used.
Never seen it, but really want:
#define MAGIC "more magic"
We have a bunch of magic #defines here that we use as the kernal of license keys...
I once worked for a school board as a programmer of COBOL reports. In order to comply with desegregation directives, it was necessary to track enrollment and attendance by race. As a result, many of the reports contained counts of students in the categories White, Black, Latino, Asian, Native American, etc.
For some reason I thought it would be amusing to globally change all the category names to their...shall we say slang equivalents?...and then go ask the boss for some help debugging a counter overflow problem. Discretion prevents me from writing down what the actual names were but you get the drift.
Took him a couple of minutes to notice. His reaction was funny as hell. Damn near got me fired, though.
#define ADMIN "Admin"
function signature that look like:
void FAR PASCAL function()...
where:
#define FAR far
#define PASCAL __stdcall
Here is one right from our own community.
#define TRUE 0
#define FALSE 1
Is if(TRUE) a good idea in C?
#define WTF "What the... ?"

Related Links

Global constants in Dragon NaturallySpeaking's advanced scripting
What are the “hidden constants”?
Are there a constants in scapy for TCP and UDP?
Where can I find a list of constants for Request Transaction Types for Authorize.Net's API?
When we will consider the constants in asymptotic notations?
Why does Pybrain predict always the same value ?
How can I set a constant in autoconf checking for a program?
Error: <signal> is not a constant
What is the write constant [duplicate]
can a constant pointer be changed during for iterations?
What is the value of ABAP constants with prefix “%_”?
introducing constants in solve function
private type declaration is throwing error?
What is the syntax for declaring a constant string[char] AA?
How to store second (time) as a constant on ios?
How exactly does the “let” keyword work in Swift?

Categories

HOME
jdbc
meshlab
reverse-engineering
checkbox
concourse
safari
wampserver
phonegap-cli
quill
filter
lotus-notes
wicket
ssr
xul
dlib
rhapsody
jive
ng2-dragula
nmake
os161
auditing
switching
metis
edge-detection
pcre
gzip
dd-wrt
red-black-tree
crt
twitter-bootstrap-2
modulo
.net-assembly
bigcartel
infusionsoft
dart-pub
intellij-idea-2016
ical-dotnet
sendgrid-templates
mediawiki-extensions
google-account
median
php-ews
sapui
ogre3d
maintenance
cdk
teiid
visual-studio-templates
adler32
shinyjs
android-navigationview
tomee
spoofing
emokit
inet
fill
eml
direct3d12
jenkins-scriptler
lmfit
mysqldumpslow
response-headers
futuretask
sevenzipsharp
adobe-indesign
uptodate
ticket-system
pgagent
grunt-contrib-concat
sortable
snmp4j
eclipse-classpath
dache
jstack
crystal-reports-10
ksoap2
sim900
java.util.date
layered
asp.net-mvc-scaffolding
nscolor
sharpmap
pep8
client-library
wpdb
pstree
responsetext
flexicious
gtk2hs
rijndael
post-redirect-get
msn
hibernate3-maven-plugin
task-management
rtsp-client
openvg
castle-validators
data-execution-prevention

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App