Questions tagged [magic-numbers]

Magic numbers are unexplained values that often should be replaced with a named constant.

193 questions
0
votes
2 answers

How do you get chunks of binary files in PHP?

I'm creating a PHP app that at some point will download an SFX archive from a website and needs to extract the data from it. Since I am running this on a Linux box, I need to chop off the SFX executable portion of the file and save the compressed…
jzimmerman2011
  • 1,806
  • 2
  • 24
  • 37
0
votes
1 answer

iPhone Configuration Utility does not install MDM Configuration profile

The setup: iPhone Configuration Utility for Windows, version 3.5.0.289 iPhone (3G?) Software version 4.3.5 (8L1) Default MDM configuration. The MDM service is using Apple's Ruby reference implementation if it matters. When trying to install a…
Mikkel Løkke
  • 3,710
  • 23
  • 37
0
votes
2 answers

Finding Magic Numbers With Regex

I'm working with a syntax highlighting control and I have to specify all of the highlighted stuff with Regex. I've completed everything else (keywords, functions, strings, comments, etc.) already but I can't come up with a good rule for magic…
Freesnöw
  • 30,619
  • 30
  • 89
  • 138
0
votes
2 answers

Inserting magic number into class files

I have a jar in which all of the class files have their magic number and type removed, I am not very knowledgeable about this specific area. What would be the best way to go about adding back in 0XCAFEBABE and the type back into each classfile and…
SwipeX
  • 11
  • 5
-1
votes
1 answer

Avoiding checkstyle MagicNumber error when filling object with magic numbers

I use magic numbers in class member initialization: private static final RangeMap MY_MAP = new ImmutableRangeMap.Builder() .put(Range.closed(10, 31), "random string 1") .put(Range.closed(32, 36),…
Michal Špondr
  • 1,337
  • 2
  • 21
  • 44
-1
votes
1 answer

how does a pointer becomes of adress 0xabababababababab or 0xfeeefeeefeeefeee?

Im working on a data structures assignmnet and something very strange is happening , my structure contains of 4 avl trees , in the destructor of the structre I delete the 4 trees using delete (the trees are allocated with new in the constructor) , a…
-1
votes
1 answer

(C++) I have to use magic numbers to display values in the correct position in an array. How can I get rid of it?

Sorry if the code is too long. I just wanted to give a detailed description of the situation I am facing I'm coding a game called Battle Ship. The following code is a simpler version, I did eliminate all the unnecessary logic, cause I just want to…
Nhung
  • 1
  • 3
-1
votes
1 answer

What hex code do .java files start with?

I'm trying to get the "magic number" (the bytes that say what format the file is)... I did try to open the file myself in a hex editor. But I only get "70 75" at the start. And that's wrong. I'm doing homework and can't find the right hex code. I do…
minteks
  • 23
  • 2
-1
votes
1 answer

In order to validate an image file I have checked the magic number of the file .Is it possible to change the magic number of the files?

My requirement is to check whether the file is jpeg / jpg / png . I have written the following code. public boolean isFileValid(File file) throws IOException { DataInputStream input = new DataInputStream(new BufferedInputStream(new…
Smrita
  • 1,259
  • 3
  • 18
  • 38
-2
votes
1 answer

Where to add magic numbers in my project?

I have a lot of magic numbers and strings in my project and I would like to replace them with constants. The thing is I remember I used, a lot of time ago, a class to hold all the constants that I would call in the code statically. It is a…
-2
votes
1 answer

How to read a file fast for checking signature/magic number?

I'm a student and I'm pretty new to C++ and security. I've been given an assignment about checking the signature/magic number in a file, and I'm having a little problem about speeding up the reading time. My idea is to read the file in binary mode…
-4
votes
1 answer

Explanation of C++ Code

I'm currently working on a program that outputs the number 1089 (i.e the Magic Number) of a three digit integer who's first digit is greater than its last. I have some code typed up, but am not receiving 1089, instead I'm receiving 891. Could anyone…
deathcat05
  • 429
  • 1
  • 5
  • 18
-4
votes
2 answers

How to get rid of magic numbers background

I'm getting magic numbers for jpanel background. Is there a way to get rid of this since it's bad practice: panel.setBackground(new color (255,255,0)); How can I have custom colors too?
1 2 3
12
13