<<The C programming language>> has an Exercise.
Convert a String of hexademical digits into a Int.
#include <stdio.h>
int hexaDecimalToDecimal(char s[])
{
if(s[0]!='0') return -1;
if(s[1]!='X' && s[1]!='x') return -1;
int i=2;
int sum=0;
while(s[i]!='\0')
{
if(s[i]>='a' && s[i]<='f') s[i]=s[i]-'a'+10;
else if(s[i]>='A' && s[i]<='F') s[i]=s[i]-'A'+10;
else if(s[i]>='0' && s[i]<='9') s[i]=s[i]-'0';
sum=sum*16+s[i];
i++;
}
return sum;
}
int main()
{
char s[]="0xb1A";
printf("%s",s);
printf(" 十进制为:%d\n",hexaDecimalToDecimal(s));
printf("%d",0xb1a);
}
分享到:
相关推荐
The MNIST database of handwritten digits, available from this page, has a training set of 60,000 examples, and a test set of 10,000 examples. It is a subset of a larger set available from NIST. The ...
This article describes some of the methods used to get the world record of the computation of the digits of digits using an inexpensive desktop computer.
spigot 算法求π的最初始的论文,英文版
Each telephone number consists of a string composed of decimal digits, uppercase letters (excluding Q and Z) and hyphens. Exactly seven of the characters in the string will be digits or letters.
Count the frequency distribution of units digits
MNIST Database of Handwritten Digits for MATLAB.zip
There is a substantial exposition of the recent history of the computation of digits of pi, a discussion of the normality of the distribution of the digits, and new translations of works by Viete and...
There is a substantial exposition of the recent history of the computation of digits of pi, a discussion of the normality of the distribution of the digits, and new translations of works by Viete and...
There is a substantial exposition of the recent history of the computation of digits of pi, a discussion of the normality of the distribution of the digits, and new translations of works by Viete and...
There is a substantial exposition of the recent history of the computation of digits of pi, a discussion of the normality of the distribution of the digits, and new translations of works by Viete and...
There is a substantial exposition of the recent history of the computation of digits of pi, a discussion of the normality of the distribution of the digits, and new translations of works by Viete and...
There is a substantial exposition of the recent history of the computation of digits of pi, a discussion of the normality of the distribution of the digits, new translations of works by Viete and ...
描述水题的细节问题。 不会就看,这题没什么技术含量.
”), articles presenting new and often amazing techniques for computing digits of pi (e.g., the “BBP” algorithm for pi, which permits one to compute an arbitrary binary digit of pi without needing ...
We describe a hardware-oriented design of a complex division algorithm proposed in .6 This algorithm is similar to a radix-r digit-recurrence division algorithm with real operands and prescaling. ...
Each telephone number consists of a string composed of decimal digits, uppercase letters (excluding Q and Z) and hyphens. Exactly seven of the characters in the string will be digits or letters. ...
Each telephone number consists of a string composed of decimal digits, uppercase letters (excluding Q and Z) and hyphens. Exactly seven of the characters in the string will be digits or letters. ...
解决的任务代码战 JavaScript [4ky] /* Description: We need to sum big numbers and we require your help. ...The input is a string of only digits The numbers are positives */ function add(a, b) {
c代码-check digit wrght by first single digit and first group of five digits and secand group of five digits