Heya!
What is the difference between a cast:
And a something:Code:(long) 10000000
Done! Thanks in advanced ขอบคุณล่วงหน้านะครับCode:10000000L
Heya!
What is the difference between a cast:
And a something:Code:(long) 10000000
Done! Thanks in advanced ขอบคุณล่วงหน้านะครับCode:10000000L
10000000 is a literal value. Its type is the smallest of int, long int, or long long int supported by your compiler. The (long) type conversion converts that value from whatever its type is to long. (Note that the C standard did not require support of long long types before 1999).
10000000L is a literal value with type long. No type conversion is required. The 'L' suffix tells the compiler the value is of type long.
There is not much difference in your example, practically, since the maximum value of a long is guaranteed to exceed 10000000.
You might want to ask how the two forms would be different if the value you supplied exceeds what your compiler's long type can represent (e.g. 3000000000 - a value that is not guaranteed to be representable using a long type - rather than 10000000). The first form potentially compiles but then gives undefined behaviour. The second form may not compile with every compiler (the actual range of values a long can support is implementation defined i.e. compiler dependent) but is guaranteed to work if it compiles.
The first one would fail to compile if the compiler used 16-bit ints.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
Ok thanks all.
Dis thread iz now solved! C: