LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Decimal to Hex

  I have a decimal integer of 100, I want to deal with it as a hex value, that is to say,this vaule is regarded as decimal 256. Is there any  easy way to do that in CVI?
0 Kudos
Message 1 of 4
(3,538 Views)

It's not exacly clear to me, what you want do to.

Does

#include <ansi_c.h>

char * s ="100";

int a;

sscanf( s,%x,&a);

do what you want ?

0 Kudos
Message 2 of 4
(3,530 Views)

Thanks, I got it. What I wanted to do was:

int i=100 ;

char *temp[1024]="\0";        

Scan (temp, "%s>%d", &i);
           Fmt (temp, "%s<%x[w4p0]", i);  // the value i will be 256

 

 

Regards!

Jacky

 

 

 

0 Kudos
Message 3 of 4
(3,525 Views)

How about:

    int i = 100;
    int v = 0;

    do {
        v = v * 16 + i % 10;
    } while (i /= 10);

JR

0 Kudos
Message 4 of 4
(3,515 Views)