Getting the Hex values

  • Steve Jones - SSC Editor

    SSC Guru

    Points: 717951

    Comments posted to this topic are about the item Getting the Hex values

  • Jeff Moden

    SSC Guru

    Points: 996046

    The correct answer (according to me :D) isn't available in the list of answers.  The correct answer would be to do it in T-SQL. 😀

    --Jeff Moden

    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
    "If you think its expensive to hire a professional to do the job, wait until you hire an amateur."--Red Adair
    "Change is inevitable... change for the better is not."

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • George Vobr

    SSCrazy Eights

    Points: 9123

    Yesterday I gave up QotD after I couldn't decide which way was best. I wrote DecToHexa (n) function, which may be the answer # 1.

    According to docs Built-in Functions this may be the answer # 3.

    According to Type Conversion in Python, this may be the answer # 4.

    But in my life sport sometimes taught me losing too. I swear I haven't looked for the right answer yet, and now I'm boldly answering # 4. Hmm... I got it wrong. Anyway thanks Steve for this funy question. Jeff was right ...

    # Function definition is here
    def DecToHexa(n):
    result = str(hex(n))
    return result;
    # Now you can call DecToHexa function
    n = 254
    result = DecToHexa(n);
    print('Hexadecimal value of '+ str(n) +' is: ' + result);

    Result pane:
    Hexadecimal value of 254 is: 0xfe

    • This reply was modified 1 week, 2 days ago by  George Vobr.
  • Stewart "Arturius" Campbell

    SSC Guru

    Points: 71680

    Nice one, thanks Steve

    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    “libera tute vulgaris ex”

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply