Last minute geek

last minute tech news from around the net

Thursday, Sep 20th

Last update01:00:00 AM

You are here: English WTF CodeSOD: Classic WTF: Quantum Computering

CodeSOD: Classic WTF: Quantum Computering

User Rating: / 0
PoorBest 
When does anything but [0-9A-F] equal "2222"? Well, it's a holiday in the US today, so take a look at this classic WTF where that's exactly what happens… -Remy

A little while back, I posted a function that generated random hexadecimal-like strings for a GUID-like string to identify events. At first, I thought it (and the rest of the system that Taka's company purchased) was just bad code. But now that I look at it further, I'm stunned at its unbelievable complexity. I can honestly say that I've never seen code that is actually prepared to run a quantum computer, where binary just isn't as simple as 1's and 0's ...

Function hex2bin(hex)
  Select Case hex
    Case "0"
      hex2bin = "0000"
    Case "1"
      hex2bin = "0001"
    Case "2"
      hex2bin = "0010"
    Case "3"
      hex2bin = "0011"
    Case "4"
      hex2bin = "0100"
    Case "5"
      hex2bin = "0101"
    Case "6"
      hex2bin = "0110"
    Case "7"
      hex2bin = "0111"
    Case "8"
      hex2bin = "1000"
    Case "9"
      hex2bin = "1001"
    Case "A"
      hex2bin = "1010"
    Case "B"
      hex2bin = "1011"
    Case "C"
      hex2bin = "1100"
    Case "D"
      hex2bin = "1101"
    Case "E"
      hex2bin = "1110"
    Case "F"
      hex2bin = "1111"
    Case Else
      hex2bin = "2222"
  End Select
End Function

The library codefiles for this system has plenty of other ultra-advanced functions. We'll have to explore these another day, but I will leave you with this method of handling quantum hexadecimal ...

Function hex2dec(hex)
  Select Case hex
    Case "0"
      hex2dec = 0
    Case "1"
      hex2dec = 1
    Case "2"
      hex2dec = 2
    Case "3"
      hex2dec = 3
    Case "4"
      hex2dec = 4
    Case "5"
      hex2dec = 5
    Case "6"
      hex2dec = 6
    Case "7"
      hex2dec = 7
    Case "8"
      hex2dec = 8
    Case "9"
      hex2dec = 9
    Case "A"
      hex2dec = 10
    Case "B"
      hex2dec = 11
    Case "C"
      hex2dec = 12
    Case "D"
      hex2dec = 13
    Case "E"
      hex2dec = 14
    Case "F"
      hex2dec = 15
    Case Else
      hex2dec = -1
 End Select
End Function
[Advertisement] ProGet can centralize your organization's software applications and components to provide uniform access to developers and servers. Check it out!

Read all
Comment Policy:
We pre-moderate any comments and welcome all kinds of thoughts, supportive, dissenting, critical or otherwise. We delete or censor comments that are:

* abusive
* off-topic
* contain personal attacks, or against any company or organization
* promote hate of any kind
* use excessively foul language
* is blatantly spam or advertising

We do not discriminate based on the person who is posting, and we never censor comments for political or ideological reasons. We never delete an appropriate comment because we disagree with its viewpoint or ideology, and we never publish an inappropriate comment because we agree with or support its viewpoint or ideology.


Attention spammers: we manually approve all comments. Spamming and blatant advertising will NOT be published on this site and is deleted immediately, you've been warned, do not waste your time here.

Add comment

Security code
Refresh