![]() This uses the ASCII code along with the char Here's another method to print the "%" (percent symbol). The first example just prints the % symbol. How, then, do you print the actual % symbol itself? For example, what if you want to print a percentage and denote it using the % symbol? To print the percent symbol in Freemat, add "%%" to the string, as shown below: The printf function uses the percent (%) symbol as a means to identify special formatting. The number corresponds to the ASCII code for the desired character. %c: character requiring an integer number between 0 - 255. ![]() This next example uses the division sign. > printf('The current exchange rate is %c%4.2f to every $1.\n',163,pounds) The current exchange rate is £0.62 to every $1. This uses the %c format with a code of 163, which will print the British pounds This first, short example shows how to display a currency exchange rate between US dollars and British pounds. Multiplication sign (more subtle than just usingĮxample - Printing with Special Characters Symbol for the angstrom, or 10 -10 meters. Greek letter "mu", which represents "micro" or I've found the following codes useful for scripts in which I wanted to print certain characters. If you would like to find out what characters go with which ASCII codes, use the following script. Where: %c is the formatting for the character to be printed It allows for the printing of special characters using the character format (%c) followed by the appropriate ASCII code (an integer between 1 - 255). This is where the character format comes in handy. And, depending where you are in the world, you may have different characters available on your keyboard than the keyboard I'm using here in the United States. You don't need to use the character format. For many special characters, such as $, #,
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |