2 Replies - 1047 Views - Last Post: 20 February 2012 - 02:44 PM Rate Topic: -----

#1 Dorito_125  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 88
  • Joined: 13-December 08

Bad Variable Declaraton

Posted 19 February 2012 - 06:57 PM

This may not constitute for bad code but it was a pretty nasty bug that was difficult to track.
final int SMALL_BOX_PRICE = 060;

Doing a simple
System.out.println(SMALL_BOX_PRICE);

yields an output of: 48.

I'm big enough to say that I was the author. I originally wrote the program using doubles and the price was written 0.60 I went back and changed it to int and erased the decimal point without getting rid of the leading 0. I won't make that mistake again!

Is This A Good Question/Topic? 3
  • +

Replies To: Bad Variable Declaraton

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3576
  • View blog
  • Posts: 10,441
  • Joined: 08-June 10

Re: Bad Variable Declaraton

Posted 20 February 2012 - 06:09 AM

View PostDorito_125, on 20 February 2012 - 02:57 AM, said:

I'm big enough to say that I was the author. I originally wrote the program using doubles and the price was written 0.60 I went back and changed it to int and erased the decimal point without getting rid of the leading 0. I won't make that mistake again!

that's the good point about it, you'll never make that mistake again. *gg*
Was This Post Helpful? 2
  • +
  • -

#3 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1253
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: Bad Variable Declaraton

Posted 20 February 2012 - 02:44 PM

Oh snap! +1
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1