using unsigned long error

Hi
im trying to convert HEX to Decimal....

unsigned long cAll1 = strtol(BABB97AE, NULL, 16);

BUT , BABB97AE = 3132856238 what i get is 2147483647 and that is the max og "long" that is why i use unsigned that should hold 4294967295 and that is fine....

info from Arduinos own page unsigned long

Use strtoul() instead.

First,

You don't convert from dec to hex or anything else!

You represent a number in deimal/Hex so

A is the number ten when written in Hex. But we do not write it simply as A we write 0xA the 0x tell us and the compiler that we have written the number in hex.

There is no such thing as a decimal number or a hex number there is only the number. We write/represent numbers in decimal or hex or ........ formats.

Second,

Strings are always written using double quotes eg "a string"

So you should just have written

unsigned long cAll1 = 0xBABB97AE;

If you do want to use any of the strXXX functions in a case like this (and I can't see why you would) then you must use the double quotes ie "BABB97AE".

BABB97AE is just an identifier (a variable name) it is not the hex representation of a number.

Mark

@jremington

thx for that it worked great