• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Character constant

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
In general if I give an input string like "0x0001" and If I extract the single characters then it will be interpreted as a character. Ex: If I extract the 3rd character from the string '0' will be extracted and if I do some arithmetic operations like multiplication then the ascii value of '0' ie. 48 will be mulitiplied with the value with which I am multiplying. Instead I want integer 0 to get multiplied with some other value in this example and not the ascii of '0' ie. 48. How it can be implemented in C? kindly let me know if anybody knows the answer
Thanks & Regards,
Prathiba
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you really asking about C here in the beginner's Java forum?
In 'C', the traditional technique is just to use (c - 48) as the value of a decimal digit, where c is a character known to be in the range 0-9. If the character is a-D or a-d, then you have to check for those and use 10-15.
In Java, you can use the static method Character.getNumericValue() method, which can handle decimal and hexidecimal digits for many international character sets.
 
There is no greater crime than stealing somebody's best friend. I miss you tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic