Code Funnies

Page 1 of 1

6 Replies - 2107 Views - Last Post: 21 June 2012 - 07:30 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=283467&amp;s=569f3fd4fac4a7f236c7ef32897a7f7e&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 Bort

• Ill-informed Mongoloid

Reputation: 450
• Posts: 3,114
• Joined: 18-September 06

Code Funnies

Posted 21 June 2012 - 06:51 AM

I spotted this ina piece of code I am trying to decipher, and it made me giggle...

```Public Const INFINITE As UInt32
```

Infinity in an unsigned 32-bit Integer.
Is This A Good Question/Topic? 0

Replies To: Code Funnies

#2 Ryano121

• D.I.C Lover

Reputation: 1380
• Posts: 3,021
• Joined: 30-January 11

Re: Code Funnies

Posted 21 June 2012 - 07:09 AM

What value does it take on?

#3 Bort

• Ill-informed Mongoloid

Reputation: 450
• Posts: 3,114
• Joined: 18-September 06

Re: Code Funnies

Posted 21 June 2012 - 07:10 AM

This one:

&HFFFFFFFFUI

#4 jon.kiparsky

• Pancakes!

Reputation: 8756
• Posts: 15,073
• Joined: 19-March 11

Re: Code Funnies

Posted 21 June 2012 - 07:14 AM

Negative 1 != infinity

(XFFFFFFFF represents a "quiet NAN" in IEEE floating-point representation, but this is an int, presumably twos-complement, so XFFFF FFFF would represent -1)

#5 Ryano121

• D.I.C Lover

Reputation: 1380
• Posts: 3,021
• Joined: 30-January 11

Re: Code Funnies

Posted 21 June 2012 - 07:15 AM

Interesting variable naming decision.

This post has been edited by Ryano121: 21 June 2012 - 07:16 AM

#6 Bort

• Ill-informed Mongoloid

Reputation: 450
• Posts: 3,114
• Joined: 18-September 06

Re: Code Funnies

Posted 21 June 2012 - 07:18 AM

jon.kiparsky, on 21 June 2012 - 08:14 AM, said:

Negative 1 != infinity

(XFFFFFFFF represents a "quiet NAN" in IEEE floating-point representation, but this is an int, presumably twos-complement, so XFFFF FFFF would represent -1)

So, Infinity is in fact -1?

Excellent. I think we've just solved one of the world's biggest questions there. How big can infinity get? Apparently, not very

#7 jon.kiparsky

• Pancakes!

Reputation: 8756
• Posts: 15,073
• Joined: 19-March 11

Re: Code Funnies

Posted 21 June 2012 - 07:30 AM

INFINITY is negative 1. Which makes sense. If you start at zero and keep adding 1 forever, that's as far as you'll get...

BTW, my bad: I forgot that we're looking at an unsigned. So that's going to be just boring old 16^8-1, I guess.