Cast
Details

- Cast is only available in compiled code.
- Possible values of method in Cast[val,type,method] include:
-
"BitCast" reinterprets the bits representing val as having the type type "CCast" emulates the behavior of casting in C "ConversionCast" converts val to the type type - The default casting method is "ConversionCast".
- Cast[val,type,"BitCast"] behaves as though val is written to memory and read back as type.
The input type to a bitcast must have the same memory size as the output type. - Cast[val,type,"CCast"] only supports numeric types.
- Cast[val,type,"ConversionCast"] can fail with an error.
Examples
open all close allBasic Examples (2)
Scope (2)
Related Guides
History
Text
Wolfram Research (2022), Cast, Wolfram Language function, https://reference.wolfram.com/language/ref/Cast.html.
CMS
Wolfram Language. 2022. "Cast." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Cast.html.
APA
Wolfram Language. (2022). Cast. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Cast.html
BibTeX
@misc{reference.wolfram_2025_cast, author="Wolfram Research", title="{Cast}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/Cast.html}", note=[Accessed: 15-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_cast, organization={Wolfram Research}, title={Cast}, year={2022}, url={https://reference.wolfram.com/language/ref/Cast.html}, note=[Accessed: 15-August-2025]}