Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TYpecasting
#11
If the long value is in the range that can be represented by the byte it is the coresponding value. I have to look up what happens otherwise, but I think it's undefined behavior.

If you want to reinterpret the value, you'd have to use
"*(unsigned char*)(&long_source)" in C and "reinterpret_cast<unsigned char&>(long_source)" in C++. But something like that is rarly used.
Reply
#12
Conversion is done implicity in FB, you can do byte = double for example, but you have yet CINT(), CBYTE(), CSHORT(), CSNG(), CDBL() if you want to do that explicitly -- and CSIGN()/CUNSG() if you want to change from signed to unsigned or the inverse.

There's no pointer type casting, yet..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)