LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

type size issue

Hi,

 

I have a numeric control. The type is unsigned int(0- 4 294 967 295). I try to get the value in an unsigned int variable with GetCtrlVal() but when the value is upper than 2 147 483 647, the value is negative. There is a mismatch between the two types. I tried to use unsigned long int, same problem.

 

Somebody already had this problem? Or somebody know how I can solve my problem.

 

Thanks everyone.

0 Kudos
Message 1 of 7
(3,102 Views)

Hi,

 

I tried to reproduce what you have described but could not succeed in observing the same behaviour.

 

If I set the control type as unsgined int and pass an unsigned int variable to GetCtrlVal function, it works as expected.

 

If you see a negative sign that means the variable is signed, so be sure you pass the correct variables.

S. Eren BALCI
IMESTEK
0 Kudos
Message 2 of 7
(3,089 Views)

Maybe the problem happens in my version. I'm using Labwindows/CVI 8.1.1

 

I checked my variables, they are Unsigned int, and when I display the value (printf), I have the negative one. I can do what I want even with this problem, but it's embarrassing.

 

Thanks for your help and your time.

0 Kudos
Message 3 of 7
(3,084 Views)

are you sure that you use the correct format specifier in printf?

0 Kudos
Message 4 of 7
(3,082 Views)

wooooowwwwww!!! So many years I program in C code, and I discover %u to display an unsigned int. :s

 

I am so sorry. Thanks a lot for your help. I ashamed, but you are very helpful. 😄

0 Kudos
Message 5 of 7
(3,080 Views)

don't worry, it happens Smiley Wink

0 Kudos
Message 6 of 7
(3,077 Views)

Johandball,

 

Something like this might help you with format types 😉

 

http://msdn.microsoft.com/en-us/library/75w45ekt(v=vs.80).aspx

 

Regards,

Eric M. - Senior Software Engineer
Certified LabVIEW Architect - Certified LabVIEW Embedded Systems Developer - Certified LabWindows™/CVI Developer
Neosoft Technologies inc.

0 Kudos
Message 7 of 7
(3,072 Views)