SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 8 of 8
  1. #1
    Member
    Join Date
    Jan 2005
    Posts
    47
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Converting hex string to int

    I've got a string that's in hexadecimal. I need to convert this to an integer. I don't mind writing the function, but is there one already available?

    I basically want something that can spit back '10' from this:

    Val("0xa")

    'cept that doesn't work.

  2. #2
    Senior Member
    Join Date
    Apr 2008
    Location
    Hyderabad
    Posts
    339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Converting hex string to int

    try this
    <font class="small">Code:</font><hr /><pre>
    [ ] INTEGER i = 0xa
    [ ]
    [ ] Print(Val(Str(i)))
    </pre><hr />

    Here first we need to store the value into a INTEGER type then you convert into a string because Val() functions accepts only string type.

    I hope this helps you.
    Regards,
    Krishna Chaitanya

    =====================
    Try and fail, but don't fail to try
    =====================

  3. #3
    Senior Member
    Join Date
    Feb 2009
    Posts
    126
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Converting hex string to int

    Intresting.
    Good to know this!
    Thanks!
    HelloWorld

  4. #4
    Member
    Join Date
    Jan 2005
    Posts
    47
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Converting hex string to int

    I can't do that. I'm starting with a string. It's being read from somewhere else.

  5. #5
    Senior Member
    Join Date
    Oct 2002
    Location
    England
    Posts
    368
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Converting hex string to int

    Use TonyM's routine, intHex2Dec.

  6. #6
    Junior Member
    Join Date
    Mar 2009
    Posts
    6
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Converting hex string to int

    How do you append an int to a string?

    writeToFileRes("Number of tests performed in test case - " + testCounter)

    testCounter is an int and I need to append to a string

  7. #7
    Senior Member
    Join Date
    Apr 2008
    Location
    Hyderabad
    Posts
    339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Converting hex string to int


    try this,

    writeToFileRes("Number of tests performed in test case - " + Str(testCounter))
    Regards,
    Krishna Chaitanya

    =====================
    Try and fail, but don't fail to try
    =====================

  8. #8
    Senior Member
    Join Date
    Apr 2008
    Location
    Hyderabad
    Posts
    339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Converting hex string to int

    No problem then you can assign it to an integer, then use Str() function to convert it into string then apply val() function.

    Here you can only obtain the exact result if and only if the variable is integer string, not a normal string.If you don't do that you may get wrog result like "0".
    Regards,
    Krishna Chaitanya

    =====================
    Try and fail, but don't fail to try
    =====================

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 9.38%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 09:43 AM.

Copyright BetaSoft Inc.