Jump to content
  • Advertisement
Sign in to follow this  
DevFred

funny (but useful) code

This topic is 3669 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I just found a funny way to express a function that maps 0 -> 1 n -> n
int atleast1(int to_be)
{
    return to_be | !to_be; // that is the question :-)
}
Care to share your funny code? :)

Share this post


Link to post
Share on other sites
Advertisement
Works best with a verbose syntax (this is, theoretically, VB):

Dim The_Cows_Come_Home as Boolean
The_Cows_Come_Home = False
Loop
The_Cows_Come_Home = Foo()
Until The_Cows_Come_Home

Share this post


Link to post
Share on other sites
const int change = 1;

In VB.Net:

Enum Food
Yum = 1
End Enum

Sub Sandwich()
Dim Sum As Food
End Sub


Can you tell I like food? :P

Share this post


Link to post
Share on other sites
Quote:
Original post by TheUnbeliever
Works best with a verbose syntax (this is, theoretically, VB):

Dim The_Cows_Come_Home as Boolean
The_Cows_Come_Home = False
Loop
The_Cows_Come_Home = Foo()
Until The_Cows_Come_Home
We have widely use production code for an embedded device with loops exactly like that, along with functions like MilkTheCows().

Share this post


Link to post
Share on other sites
I kinda like the errors the VS debugger puts for bad memory pointers:

0xDEADC0DE
0xDEADBEEF
0xBAADF00D

Other combinations include:

0xABADFACE
0xBEDCAFE
0xBE2FACED

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!