Home Page | Language Reference (extended) | SD Reference | Libraries | Comparison | Changes
Constructs an instance of the String class. There are multiple versions that construct Strings from different data types (i.e. format them as sequences of characters), including:
Constructing a String from a number results in a string that contains the ASCII representation of that number. The default is base ten, so
String thisString = String( 13 ) ;
gives you the String "13". You can use other bases, however. For example, >
gives you the String "13". You can use other bases, however. For example, >
gives you the String "13". You can use other bases, however. For example, > [Get Code]
gives you the String "D", which is the hexadecimal representation of decimal value 13. Or if you prefer binary, >
gives you the String "D", which is the hexadecimal representation of decimal value 13. Or if you prefer binary, >
gives you the String "D", which is the hexadecimal representation of decimal value 13. Or if you prefer binary, > [Get Code]
gives you the String "1101", which is the binary representation of 13.>
String(val)
String(val, base)
String(val, decimalPlaces)
val: a variable to format as a String - string, char, byte, int, long, unsigned int, unsigned long, float, double
base (optional) - the base in which to format an integral value
decimalPlaces (only if val is float or double) - the desired decimal places
an instance of the String class
All of the following are valid declarations for Strings.
gives you the String "1101", which is the binary representation of 13.>
gives you the String "1101", which is the binary representation of 13.> [Get Code]
Corrections, suggestions, and new documentation should be posted to the Forum.
The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.