Options

PA Programming Thread - The Best Servers Are The Ones You Don't Use

1535456585963

Posts

  • Options
    Warlock82Warlock82 Never pet a burning dog Registered User regular
    edited March 2011
    Okay now it doesn't throw an error, but echo $names is the same before and after the foreach loop.

    Oh, that's because you are setting an arbitrary variable (I) and not doing anything with it :P You need to store the results in something.

    Like:


    foreach I ($names)
    set I="${I}[14]"
    set newnames="${newnames}\n${I}" #or whatever the hell is delimiting $names, I assumed a return
    End

    set names="${newnames}"

    Warlock82 on
    Switch: 2143-7130-1359 | 3DS: 4983-4927-6699 | Steam: warlock82 | PSN: Warlock2282
  • Options
    bowenbowen How you doin'? Registered User regular
    edited March 2011
    So I said earlier that I was writing a really simple Java game, just as a programming exercise, and I have a quick question. I have an engine class that contains the world object, which contains all the other objects, and it does some things like reading from files and setting up the world. I'm thinking I should make it static, so that I can access it from every other class. Is this a good idea, or do I need to continue to pass an Engine object around to all my classes?

    If a static engine isn't a good idea, can you give me another solution to the problem I'm having: my Door objects need to access the room list (stored in the world object, stored in the engine object) when they're initialised. The only way I seem to be bale to do that is to pass the engine object to the world object, from the world to the room object at initialisation, and then, if a new door needs to be made, to the door, and then the door calls engine.getRoomList(). This seems awful and messy, is there a simpler option?

    That is certainly an option.

    Let me tell you this now, best practices be damned, do what works and doesn't make your code look like an asshole that just dropped a turd.

    You don't necessarily need to make it static, you can pass a reference to the class itself, but making it static will be more obvious. I would probably concede on breaking the rules of encapsulation here because really, everything is interacting with your engine at some point.

    Your other option is to make it public instead of static and still instantiating it, and making it an enforced singleton. Which would I pick? Probably the singleton.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    durandal4532durandal4532 Registered User regular
    edited March 2011
    Haha for fuck's sake. I am a moron.

    durandal4532 on
    Take a moment to donate what you can to Critical Resistance and Black Lives Matter.
  • Options
    IcemopperIcemopper Registered User regular
    edited March 2011
    Ok I've added another post. I won't post here every time I do, though, but I certainly wouldn't mind criticism. I'm probably getting some things wrong, but I'm trying!

    Icemopper on
  • Options
    durandal4532durandal4532 Registered User regular
    edited March 2011
    Okay no I am not that dumb. It's not actually as easy as all that. It throws no match errors all over he place, and echo $I after the set command throws a no match. Argh! It's something ridiculous to do with tcsh syntax I think. I appear to be destroying the variables instead of changing their content?

    durandal4532 on
    Take a moment to donate what you can to Critical Resistance and Black Lives Matter.
  • Options
    bowenbowen How you doin'? Registered User regular
    edited March 2011
    I really like that wordpress theme icemopper.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    durandal4532durandal4532 Registered User regular
    edited March 2011
    It is definitely something specific about bracketting the 14 anything else works fine. The moment I put in a closed bracket, even escaped, it throws a no match.

    durandal4532 on
    Take a moment to donate what you can to Critical Resistance and Black Lives Matter.
  • Options
    ecco the dolphinecco the dolphin Registered User regular
    edited March 2011
    Okay no I am not that dumb. It's not actually as easy as all that. It throws no match errors all over he place, and echo $I after the set command throws a no match. Argh! It's something ridiculous to do with tcsh syntax I think. I appear to be destroying the variables instead of changing their content?

    Quick dirty hack time!

    set names='ls l cut -d.-f1 l uniq | sed s/$/[14]/'

    You may need to escape some characters (e.g. $)

    ecco the dolphin on
    Penny Arcade Developers at PADev.net.
  • Options
    IcemopperIcemopper Registered User regular
    edited March 2011
    bowen wrote: »
    I really like that wordpress theme icemopper.

    Horray for standard themes! And thanks, I figured plain was better than noisy for this type of blog.

    Icemopper on
  • Options
    durandal4532durandal4532 Registered User regular
    edited March 2011
    Okay no I am not that dumb. It's not actually as easy as all that. It throws no match errors all over he place, and echo $I after the set command throws a no match. Argh! It's something ridiculous to do with tcsh syntax I think. I appear to be destroying the variables instead of changing their content?

    Quick dirty hack time!

    set names='ls l cut -d.-f1 l uniq | sed s/$/[14]/'

    You may need to escape some characters (e.g. $)

    Still gives me a no match.[] appears to force it to look for wild cards for some stupid reason.

    Also I can't include a fucking space as a delimeter. Or newline. Or anything beyond more characters. Fucking scripting.

    durandal4532 on
    Take a moment to donate what you can to Critical Resistance and Black Lives Matter.
  • Options
    Warlock82Warlock82 Never pet a burning dog Registered User regular
    edited March 2011
    Okay no I am not that dumb. It's not actually as easy as all that. It throws no match errors all over he place, and echo $I after the set command throws a no match. Argh! It's something ridiculous to do with tcsh syntax I think. I appear to be destroying the variables instead of changing their content?

    Quick dirty hack time!

    set names='ls l cut -d.-f1 l uniq | sed s/$/[14]/'

    You may need to escape some characters (e.g. $)

    Haha I was going to suggest something like that, but trying to wrangle sed and its crazy regexps is always more work than I feel like doing (at least casually) :P

    Warlock82 on
    Switch: 2143-7130-1359 | 3DS: 4983-4927-6699 | Steam: warlock82 | PSN: Warlock2282
  • Options
    InfidelInfidel Heretic Registered User regular
    edited March 2011
    Okay no I am not that dumb. It's not actually as easy as all that. It throws no match errors all over he place, and echo $I after the set command throws a no match. Argh! It's something ridiculous to do with tcsh syntax I think. I appear to be destroying the variables instead of changing their content?

    Quick dirty hack time!

    set names='ls l cut -d.-f1 l uniq | sed s/$/[14]/'

    You may need to escape some characters (e.g. $)

    Still gives me a no match.[] appears to force it to look for wild cards for some stupid reason.

    Also I can't include a fucking space as a delimeter. Or newline. Or anything beyond more characters. Fucking scripting.

    Yeah, the square brackets are still not escaped properly.

    Infidel on
    OrokosPA.png
  • Options
    ecco the dolphinecco the dolphin Registered User regular
    edited March 2011
    Infidel wrote: »
    Okay no I am not that dumb. It's not actually as easy as all that. It throws no match errors all over he place, and echo $I after the set command throws a no match. Argh! It's something ridiculous to do with tcsh syntax I think. I appear to be destroying the variables instead of changing their content?

    Quick dirty hack time!

    set names='ls l cut -d.-f1 l uniq | sed s/$/[14]/'

    You may need to escape some characters (e.g. $)

    Still gives me a no match.[] appears to force it to look for wild cards for some stupid reason.

    Also I can't include a fucking space as a delimeter. Or newline. Or anything beyond more characters. Fucking scripting.

    Yeah, the square brackets are still not escaped properly.

    Yeah, it looks like square brackets are special in csh.

    So

    set names='ls l cut -d.-f1 l uniq | sed s/\$/\[14\]/'

    ?

    ecco the dolphin on
    Penny Arcade Developers at PADev.net.
  • Options
    durandal4532durandal4532 Registered User regular
    edited March 2011
    Well, even when I do escape them as in

    Set I = "$I"\"\[14\]\" it says no match. It also throws an error for any escape followed by space.

    durandal4532 on
    Take a moment to donate what you can to Critical Resistance and Black Lives Matter.
  • Options
    AnteCantelopeAnteCantelope Registered User regular
    edited March 2011
    bowen wrote: »
    So I said earlier that I was writing a really simple Java game, just as a programming exercise, and I have a quick question. I have an engine class that contains the world object, which contains all the other objects, and it does some things like reading from files and setting up the world. I'm thinking I should make it static, so that I can access it from every other class. Is this a good idea, or do I need to continue to pass an Engine object around to all my classes?

    If a static engine isn't a good idea, can you give me another solution to the problem I'm having: my Door objects need to access the room list (stored in the world object, stored in the engine object) when they're initialised. The only way I seem to be bale to do that is to pass the engine object to the world object, from the world to the room object at initialisation, and then, if a new door needs to be made, to the door, and then the door calls engine.getRoomList(). This seems awful and messy, is there a simpler option?

    That is certainly an option.

    Let me tell you this now, best practices be damned, do what works and doesn't make your code look like an asshole that just dropped a turd.

    You don't necessarily need to make it static, you can pass a reference to the class itself, but making it static will be more obvious. I would probably concede on breaking the rules of encapsulation here because really, everything is interacting with your engine at some point.

    Your other option is to make it public instead of static and still instantiating it, and making it an enforced singleton. Which would I pick? Probably the singleton.

    An enforced singleton? Sorry, I haven't heard of this before, what does it mean? Is it like making the engine object a global variable?

    AnteCantelope on
  • Options
    InfidelInfidel Heretic Registered User regular
    edited March 2011
    bowen wrote: »
    So I said earlier that I was writing a really simple Java game, just as a programming exercise, and I have a quick question. I have an engine class that contains the world object, which contains all the other objects, and it does some things like reading from files and setting up the world. I'm thinking I should make it static, so that I can access it from every other class. Is this a good idea, or do I need to continue to pass an Engine object around to all my classes?

    If a static engine isn't a good idea, can you give me another solution to the problem I'm having: my Door objects need to access the room list (stored in the world object, stored in the engine object) when they're initialised. The only way I seem to be bale to do that is to pass the engine object to the world object, from the world to the room object at initialisation, and then, if a new door needs to be made, to the door, and then the door calls engine.getRoomList(). This seems awful and messy, is there a simpler option?

    That is certainly an option.

    Let me tell you this now, best practices be damned, do what works and doesn't make your code look like an asshole that just dropped a turd.

    You don't necessarily need to make it static, you can pass a reference to the class itself, but making it static will be more obvious. I would probably concede on breaking the rules of encapsulation here because really, everything is interacting with your engine at some point.

    Your other option is to make it public instead of static and still instantiating it, and making it an enforced singleton. Which would I pick? Probably the singleton.

    An enforced singleton? Sorry, I haven't heard of this before, what does it mean? Is it like making the engine object a global variable?

    A singleton is a proper way to do what you want.

    You want to have one engine instance, and always refer to that one instance.

    Singleton!

    The advantage being you don't have to static everything but still ensure one object exists.

    Infidel on
    OrokosPA.png
  • Options
    AnteCantelopeAnteCantelope Registered User regular
    edited March 2011
    Infidel wrote: »
    bowen wrote: »
    So I said earlier that I was writing a really simple Java game, just as a programming exercise, and I have a quick question. I have an engine class that contains the world object, which contains all the other objects, and it does some things like reading from files and setting up the world. I'm thinking I should make it static, so that I can access it from every other class. Is this a good idea, or do I need to continue to pass an Engine object around to all my classes?

    If a static engine isn't a good idea, can you give me another solution to the problem I'm having: my Door objects need to access the room list (stored in the world object, stored in the engine object) when they're initialised. The only way I seem to be bale to do that is to pass the engine object to the world object, from the world to the room object at initialisation, and then, if a new door needs to be made, to the door, and then the door calls engine.getRoomList(). This seems awful and messy, is there a simpler option?

    That is certainly an option.

    Let me tell you this now, best practices be damned, do what works and doesn't make your code look like an asshole that just dropped a turd.

    You don't necessarily need to make it static, you can pass a reference to the class itself, but making it static will be more obvious. I would probably concede on breaking the rules of encapsulation here because really, everything is interacting with your engine at some point.

    Your other option is to make it public instead of static and still instantiating it, and making it an enforced singleton. Which would I pick? Probably the singleton.

    An enforced singleton? Sorry, I haven't heard of this before, what does it mean? Is it like making the engine object a global variable?

    A singleton is a proper way to do what you want.

    You want to have one engine instance, and always refer to that one instance.

    Singleton!

    The advantage being you don't have to static everything but still ensure one object exists.

    OK, looks pretty cool. Do I still need to pass references to that object around all the time? Or could I have a static getSingletonEngine() method to call it wherever I need it?

    AnteCantelope on
  • Options
    InfidelInfidel Heretic Registered User regular
    edited March 2011
    Infidel wrote: »
    bowen wrote: »
    So I said earlier that I was writing a really simple Java game, just as a programming exercise, and I have a quick question. I have an engine class that contains the world object, which contains all the other objects, and it does some things like reading from files and setting up the world. I'm thinking I should make it static, so that I can access it from every other class. Is this a good idea, or do I need to continue to pass an Engine object around to all my classes?

    If a static engine isn't a good idea, can you give me another solution to the problem I'm having: my Door objects need to access the room list (stored in the world object, stored in the engine object) when they're initialised. The only way I seem to be bale to do that is to pass the engine object to the world object, from the world to the room object at initialisation, and then, if a new door needs to be made, to the door, and then the door calls engine.getRoomList(). This seems awful and messy, is there a simpler option?

    That is certainly an option.

    Let me tell you this now, best practices be damned, do what works and doesn't make your code look like an asshole that just dropped a turd.

    You don't necessarily need to make it static, you can pass a reference to the class itself, but making it static will be more obvious. I would probably concede on breaking the rules of encapsulation here because really, everything is interacting with your engine at some point.

    Your other option is to make it public instead of static and still instantiating it, and making it an enforced singleton. Which would I pick? Probably the singleton.

    An enforced singleton? Sorry, I haven't heard of this before, what does it mean? Is it like making the engine object a global variable?

    A singleton is a proper way to do what you want.

    You want to have one engine instance, and always refer to that one instance.

    Singleton!

    The advantage being you don't have to static everything but still ensure one object exists.

    OK, looks pretty cool. Do I still need to pass references to that object around all the time? Or could I have a static getSingletonEngine() method to call it wherever I need it?

    Yeah, you have the static accessor and instance, everything else is non-static and acting directly on the singleton object instance. There are examples in Java in that article.

    This is the way to treat things, since you should see that "hey game engine would be nice to save state of" which means some form of serialization which means it really should be represented as an object and not a collection of static methods and globals.

    Infidel on
    OrokosPA.png
  • Options
    skettiosskettios Enchanted ForestRegistered User regular
    edited March 2011
    Boss man wants to send me to a ruby conference (even though most of my stuff is in php *shrug*) and I get to help pick one.

    I've only really heard of RailsConf.
    How is it? Are there others you'd recommend?

    skettios on
  • Options
    IcemopperIcemopper Registered User regular
    edited March 2011
    So thanks to "asimperson," I'm discovering things where I was confused about "low-level" language, and what it really means. The definitions I've found were pretty vague, but it is making more sense now after their explanation. I certainly don't mind taking an extra day or a week even to get the proper background I'd need for this kind of deal.

    Icemopper on
  • Options
    Jimmy KingJimmy King Registered User regular
    edited March 2011
    Hey guys, quick developer resume question. I have a short list of a few pesonal projects on my resume to highlight various skill sets, show my range of skills, etc. I am considering swapping one of them for something different. If you were hiring, which would impress you more?
    Current wrote:
    HTTP Inspector - HTTP Inspector is a Java application for the Android platform which makes HTTP requests to a specified URL for testing by server administrators or web application developers. The user can then view the resulting headers, raw data returned, or rendered data. Common requests can be saved in a SQLite database for reuse.
    jmXMPP - jmXMPP is an XMPP client for Android that I have been developing. It currently uses a background service for communication with the XMPP server. The user interface uses aidl to make requests through the service and receives broadcast intents generated by the service for pushed updates. The client currently contains a contact list with real time status updates of the contacts, the ability to start a new chat, and status bar notifications for incoming chat requests.

    Jimmy King on
  • Options
    bowenbowen How you doin'? Registered User regular
    edited March 2011
    Which one do you like better? I think the XMPP one shows more about you, but if you didn't finish it, it will likely be a detriment.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    Smug DucklingSmug Duckling Registered User regular
    edited March 2011
    To those complaining about Python's "print" statement, rest assured that the Python community agrees that it's weird and it's removed it in its current form (and replaced with an actual, proper built-in function) in Python 3.

    Also Python is awesome. I did a machine learning course in it, and with numpy it's muuch nicer to play around with than Matlab. Also what other language lets you do this? ;)
    # finds the first n ugly numbers, where an ugly number is a number in the form
    # 2^a * 3^b * 5^c, for a, b, c >= 0.
    def uglys(n):
      uglys = [1]
      multipliers = [2, 3, 5]
      indices = [0, 0, 0]
      while len(uglys) < n: (lambda (i, product): (uglys.append(product) if product > uglys[-1] else 0, indices.__setitem__(i, indices[i] + 1)))(min(enumerate(map(lambda (multiplier, index): multiplier * uglys[index], zip(multipliers, indices))), key=lambda (i, product): product))
      return uglys
    
    if __name__ == "__main__":
      import sys
      if len(sys.argv) > 1:
        n = int(sys.argv[1])
      else:
        n = 1000
      print uglys(n)
    
    

    As I was writing that, I kept noticing that I could combine it all into one line. The above abomination is what resulted. The built-in data manipulation functions are really wonderful. (I'm particularly fond of "min(enumerate(map(lambda" :P .)

    Smug Duckling on
    smugduckling,pc,days.png
  • Options
    bowenbowen How you doin'? Registered User regular
    edited March 2011
    Good god, that looks like something I wrote in C# one time with liberal use of tertiary operators. I was ashamed but I felt awesome. I still had to wash the shame off myself.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    Jimmy KingJimmy King Registered User regular
    edited March 2011
    bowen wrote: »
    Which one do you like better? I think the XMPP one shows more about you, but if you didn't finish it, it will likely be a detriment.
    I personally like the XMPP client better. It sounds fancier. The http header deal was more work than it actually sounds like. The XMPP client is also cleaner code for showing off since it's recent whereas the http header deal was my first Android project, so has some outdated techniques, some "I'm just learning, but this seems to work" type stuff, etc.

    The XMPP client isn't 100% finished, but I would think as long as I make it clear that it is a work in progress (I really am still actively working on it) that's ok? I mean, it works now as in it can connect to a server, shows the contact list, updates the contact list as people go on/offline or change their status, allows you to start a chat, allows people to start a chat with you, lets you switch between chats with different people, has options to save your username and password or not, etc.

    Jimmy King on
  • Options
    Jimmy KingJimmy King Registered User regular
    edited March 2011
    That python snippet reminds me. This if __name__ == "__main__: bit I keep seeing. I assume that's to create a block out in the main area where the interpreter starts parsing that has its own scope for variables and whatnot rather than having the code all out in the open there?

    Jimmy King on
  • Options
    Smug DucklingSmug Duckling Registered User regular
    edited March 2011
    Jimmy King wrote: »
    That python snippet reminds me. This if __name__ == "__main__: bit I keep seeing. I assume that's to create a block out in the main area where the interpreter starts parsing that has its own scope for variables and whatnot rather than having the code all out in the open there?

    The idea is that if you import the file, you usually don't want to run the main code from that file, and so you hide it inside a "__name__ == "__main__":" block. __name__ only equals "__main__" for foo.py if you actually ran it as "python foo.py" on the command line.

    Smug Duckling on
    smugduckling,pc,days.png
  • Options
    bowenbowen How you doin'? Registered User regular
    edited March 2011
    Jimmy King wrote: »
    bowen wrote: »
    Which one do you like better? I think the XMPP one shows more about you, but if you didn't finish it, it will likely be a detriment.
    I personally like the XMPP client better. It sounds fancier. The http header deal was more work than it actually sounds like. The XMPP client is also cleaner code for showing off since it's recent whereas the http header deal was my first Android project, so has some outdated techniques, some "I'm just learning, but this seems to work" type stuff, etc.

    The XMPP client isn't 100% finished, but I would think as long as I make it clear that it is a work in progress (I really am still actively working on it) that's ok? I mean, it works now as in it can connect to a server, shows the contact list, updates the contact list as people go on/offline or change their status, allows you to start a chat, allows people to start a chat with you, lets you switch between chats with different people, has options to save your username and password or not, etc.

    Hell if it works and sends messages to and fro you're probably fine. They'll probably ask to see it in action and source code if you're not under an NDA with it.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    Jimmy KingJimmy King Registered User regular
    edited March 2011
    Jimmy King wrote: »
    That python snippet reminds me. This if __name__ == "__main__: bit I keep seeing. I assume that's to create a block out in the main area where the interpreter starts parsing that has its own scope for variables and whatnot rather than having the code all out in the open there?

    The idea is that if you import the file, you usually don't want to run the main code from that file, and so you hide it inside a "__name__ == "__main__":" block. __name__ only equals "__main__" for foo.py if you actually ran it as "python foo.py" on the command line.
    Ah, hah. Interesting. Good stuff to know. I'm beginning to work with Python, but so far have just done a bit of reading and played with Django. The Django stuff so far hasn't required a whole lot of "real" programming.

    Jimmy King on
  • Options
    Jimmy KingJimmy King Registered User regular
    edited March 2011
    bowen wrote: »
    Jimmy King wrote: »
    bowen wrote: »
    Which one do you like better? I think the XMPP one shows more about you, but if you didn't finish it, it will likely be a detriment.
    I personally like the XMPP client better. It sounds fancier. The http header deal was more work than it actually sounds like. The XMPP client is also cleaner code for showing off since it's recent whereas the http header deal was my first Android project, so has some outdated techniques, some "I'm just learning, but this seems to work" type stuff, etc.

    The XMPP client isn't 100% finished, but I would think as long as I make it clear that it is a work in progress (I really am still actively working on it) that's ok? I mean, it works now as in it can connect to a server, shows the contact list, updates the contact list as people go on/offline or change their status, allows you to start a chat, allows people to start a chat with you, lets you switch between chats with different people, has options to save your username and password or not, etc.

    Hell if it works and sends messages to and fro you're probably fine. They'll probably ask to see it in action and source code if you're not under an NDA with it.
    Oh yeah, no NDA on this. This is just something I've been working on for fun because it's such a different skill set than what I use at work and so is fun and interesting. After I get more done I'll probably write an XMPP server in Python and/or Scala to go with it.

    I always have a few side projects and keep the code around and have the more interesting ones listed on my resume. That stuff has done far more for getting me interviews and landing the jobs than anything I've ever actually done for my job. I just can't list ALL of my side projects on the resume, so I try to keep it to 3-5 of the most interesting and/or relevant to the job I'm applying for... and least embarassing in terms of old code and most representative of my current coding style.

    Jimmy King on
  • Options
    bowenbowen How you doin'? Registered User regular
    edited March 2011
    Yeah that sounds like a plan, I'd be more interested in your XMPP app than your HTTP header app.

    Also, looks like I'm gonna snag an iPhone in the next few months. Yay I can actually learn to program for it.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    IcemopperIcemopper Registered User regular
    edited March 2011
    So... I'm a little confused on Binary... I can figure out how to count to 9, but then apparently 10 does not come after that?

    Am I missing the point?

    Icemopper on
  • Options
    bowenbowen How you doin'? Registered User regular
    edited March 2011
    Count like you would in any other base.

    Base 10 digits: 0-9
    Counting in base 10: 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17...

    Base 2 digits : 0-1
    Counting in base 2: 0,1,10,11,100,101,110,111,1000,1001,1010,1011,1101,1111...

    Base 16 digits :0-9,A-F
    Counting in base 16: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C...

    I learned this from the Rama video game when I was like 8, oh my god was that frustrating for someone with no concept of anything besides roman numerals and base 10.

    I would not be surprised if I got some of those wrong too.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    InfidelInfidel Heretic Registered User regular
    edited March 2011
    Icemopper wrote: »
    So... I'm a little confused on Binary... I can figure out how to count to 9, but then apparently 10 does not come after that?

    Am I missing the point?

    Er, well 10 decimal is 1010 binary.

    You need to think about what a base does in a number system.

    458 written out actually means 4 hundreds, 5 tens, 8 ones. I'm sure you remember the lessons like that in grade school.

    Well 1010 binary is 1 eights, 0 fours, 1 twos, 0 ones. 1 eight + 1 two = ten.

    The place value is (base ^ place) with place starting at 0 on the right and going up one each step to the left.

    So the first digit (starting on the right) of any integer in any number system is the base to the power 0, which is always the "ones". After that it changes.

    10^0 = ones
    10^1 = tens
    10^2 = hundreds
    10^3 = thousands
    etc.

    If you start looking at hexadecimal, it's the same thing.

    16^0 = ones
    16^1 = sixteens
    etc.

    Infidel on
    OrokosPA.png
  • Options
    bowenbowen How you doin'? Registered User regular
    edited March 2011
    The good news is, it is not widely used since just knowing why and how you'd count is enough. The only time I've used binary math is on enums with binary flagging. And even then, it's rare and only on platforms where space is a real issue. Outside of the classroom I don't think I've used it since.

    The hardest thing you'll probably have to do is calculate your big O notation on algos.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    EtheaEthea Registered User regular
    edited March 2011
    Bit twiddling and doing bit masks is fairly common in my domain.
    Qt still requires you to understand Bit AND and OR to do anything remotely advanced.

    Ethea on
  • Options
    bowenbowen How you doin'? Registered User regular
    edited March 2011
    Yeah bit masking is what I was referring too, that's still fairly common though I haven't seen it too often outside of embedded solutions. At least not in any C/C++ code I've touched lately, not that I've touched much of it. I think I did some bit twiddling on an int to get an ip address out of it though. I mean I can understand if you're hard for space you'd want to do that but the readability is shit, especially for someone who doesn't know it (a lot of people!). I'd just implement an int IPtoInt(string) function and make it easy on myself.

    But I'm lazy and deal with platforms with tons of space and processing so it's no biggie.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    InfidelInfidel Heretic Registered User regular
    edited March 2011
    Knowing how numeric systems work is vital to not embarrassing the fuck out of yourself when they do come up and you write code that is way stupider than it should be.

    Trust me, it happens in "normal" developer land.

    Infidel on
    OrokosPA.png
  • Options
    bowenbowen How you doin'? Registered User regular
    edited March 2011
    Man counting is for math nerds. VB for lyfe, mirite?

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    Monkey Ball WarriorMonkey Ball Warrior A collection of mediocre hats Seattle, WARegistered User regular
    edited March 2011
    bowen wrote: »
    The hardest thing you'll probably have to do is calculate your big O notation on algos.

    I'm a math minor and this still gives me trouble.

    Monkey Ball Warrior on
    "I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
This discussion has been closed.