7
14
2010
11

C51中的浮点数存储方式(转载)

 

C51中的浮点数存储方式

Float 浮点形,它是符合IEEE-754标准的单精度浮点形数据,在十进制中具有7位有效数字。FLOAT型据占用四个字节(32位二进制数),在内存中的存放 格式如下:
字节地址(由低到高)0 1 2 3
浮点数内容 MMMMMMMM MMMMMMMM E MMMMMMM S EEEEEEE
其中,S为符号位,存放在最高字节的最高位。“1”表示负,“0”表示正。E为阶码,占用8位二进制数,存放在高两个字节中。注意,阶码E值是以2为底的 指数再加上偏移量127,这样处理的目的是为了避免出现负的阶码值,而指数是可正可负的。阶码E的正常取值范围是1~254,从而实际指数的取值范围为 -126-127。M为尾数的小数部分,用23位二进制数表示,存放在低三个字节中。尾数的整数部分永远为1,因此不予保存,但它是隐含的。小数点位于隐 含的整数位“1”的后面。

例如浮点数124.75 = 42F98000H 在内存中的存放格式为:
字节地址 +0 +1 +2 +3
浮点数内容 00000000 10000000 1 1111001 0 1000010

124.75D=1111100.11B=1.11110011*2E6
阶码=6D+127D=133D=10000101B
符号位=0

 

%参考示例程序一:
typedef union{
float flt;
unsigned char fltc[4];
} Float;


main()
{
Float a;
unsigned char i;
a.flt=124.75;
for(i = 0; i < 4; i++)
printf("%x\t",a.fltc);
printf("\n");
}

%参考示例程序二:
main()
{
float a;
unsigned char i;
unsigned char *j;
a=124.75;
j = (unsigned char *)&a;
for(i = 0; i < 4; i++)
printf("%x\t",j);
printf("\n");
}

 

Category: matlab | Tags: | Read Count: 3230
Avatar_small
AAA said:
Mon, 25 Apr 2022 05:07:50 +0800

I think that thanks for the valuabe information and insights you have so provided here. Merchant Processing Agent

Avatar_small
AAA said:
Fri, 29 Apr 2022 02:11:05 +0800

I was trying to find this. Really refreshing take on the information. Thanks a lot. Merchant Services ISO

Avatar_small
UP 11th Model Paper said:
Tue, 16 Aug 2022 18:11:27 +0800

For all of the students enrolled in these institutions, this board is drafting a syllabus from Class I to Class XII. There are several schools in the state of Uttar Pradesh that are associated with this board. Every year, this board also holds exams for the ninth and eleventh grades, in which a large number of students participate. These exams' UPMSP Plus One Question Paper 2023 was released in June. <a href="https://www.edpost.in/allahabad-board-inter-question-paper/">UP 11th Model Paper 2023</a> As we know, the UPMSP Plus One Important Question Paper 2023 for class 11th of the UP Board was announced in the month of June the previous year, and we presume, there were 26 lakh students who appeared in the Class 11th UP board examinations, and the pass % of the entire students.

Avatar_small
UP 11th Model Paper said:
Tue, 16 Aug 2022 18:11:53 +0800

For all of the students enrolled in these institutions, this board is drafting a syllabus from Class I to Class XII. There are several schools in the state of Uttar Pradesh that are associated with this board. Every year, this board also holds exams for the ninth and eleventh grades, in which a large number of students participate. These exams' UPMSP Plus One Question Paper 2023 was released in June. UP 11th Model Paper 2023 As we know, the UPMSP Plus One Important Question Paper 2023 for class 11th of the UP Board was announced in the month of June the previous year, and we presume, there were 26 lakh students who appeared in the Class 11th UP board examinations, and the pass % of the entire students.

Avatar_small
AP SSC fa 2 Model Pa said:
Fri, 09 Sep 2022 19:48:11 +0800

Formative Assessment means not only an examination, it includes various aspects such as Examination in completed lessons, Reflections, Project work done on the allotted topic and Self also Prepared notes etc. AP SSC fa 2 Model Paper Candidates of Telugu Medium, English Medium & Urdu Medium of the AP State can download the AP 10th Class FA 4 Model Paper 2023 Pdf with answers for the regular exams conducted by the Directorate of Government Examinations, Andhra Pradesh.

Avatar_small
civaget said:
Thu, 14 Dec 2023 03:23:47 +0800

There are always 구글 상위노출 opportunities in your niche waiting to be discovered. Are you ready to seize them?

Avatar_small
civaget said:
Sat, 16 Dec 2023 21:14:05 +0800

포항오피's dedication to providing accurate and detailed information sets it apart from the rest.

Avatar_small
civaget said:
Tue, 19 Dec 2023 21:08:06 +0800

"오피가이드" is your passport to South Korea's OP services. Discover spas, therapies, and officetel relaxation effortlessly.

Avatar_small
civaget said:
Wed, 20 Dec 2023 21:29:43 +0800

해외스포츠중계: Uniting fans worldwide in their love for sports.

Avatar_small
civaget said:
Wed, 27 Dec 2023 23:12:37 +0800

At 이천휴게텔, I experienced a blend of relaxation and professionalism. The customizable massages cater to individual preferences seamlessly.

Avatar_small
civaget said:
Tue, 09 Jan 2024 20:33:30 +0800

툰코's user-friendly interface makes webtoon enjoyment a breeze.


Login *


loading captcha image...
(type the code from the image)
or Ctrl+Enter

| Theme: Aeros 2.0 by TheBuckmaker.com