Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the ASCII Code of ½?

I want to print the value '½' in a file. I searched for the ascii value of this as Alt+(ascii Value) will give you the same. To my surprise I found 2 ascii values for this symbol in various sites. One is 171 and the other is 189.

I tried to write this symbol by using 171 and 189. Again to my surprise, if I am writing in Windows, 171 will give me this symbol. But if I am writing in UNIX, 189 will give me this symbol.

I was aware that there cant be 2 ASCII Values for a same symbol. But I got 2 valid codes for the same symbol in different OS. So can anyone tell what is the real ASCII Code for the symbol ½ ??

like image 614
user2238999 Avatar asked Apr 03 '13 05:04

user2238999


1 Answers

As others have pointed out: it's not in the ASCII table (values 0..127).

But it has a Unicode code of:

  • ½ U+00BD Vulgar Fraction One Half

It can also be put into text using the unicode U+2044 Fraction Slash:

  • where your text contains the three code points: 12
  • but it gets rendered as 1⁄2

This has the virtue of working for any fractions:

  • 1⁄2
  • 3⁄5
  • 22⁄7
  • 355⁄113
  • 355⁄113 - 1⁄3748629
like image 74
Ian Boyd Avatar answered Oct 02 '22 15:10

Ian Boyd