"Self-use" memset for int, long long, float, double extremum how Clear

Source: Internet
Author: User
Tags 0xc0

Link:
#include <stdio.h>int main(){    puts("转载请注明出处[辗转山河弋流歌 by 空灰冰魂]谢谢");    puts("网址:blog.csdn.net/vmurder/article/details/46537613");}
Int

The principle of "more": addition does not explode.
Maximum value: 0x7f
Larger value: 0x3f
Lower value: 0xc0
Minimum value: 0x80

Long Long

The principle of "more": addition does not explode.
Maximum value: 0x7f
Larger value: 0x3f
Lower value: 0xc0
Minimum value: 0x80

Float

"More" principle: to ensure a positioning accuracy.
7f or more until be is-0 (actually a small negative number of >-1.0)
Maximum value: 0x7f
Larger value: 0x4f
Lower value: 0xce
Minimum value: 0xFE
0xFF is -1. #QNAN0000 ... (-∞?) )

Double

"More" principle: to ensure a positioning accuracy.
Maximum value: 0x7f
Larger value: 0x43
Lower value: 0xc2
Minimum value: 0xFE

Experiment Code:
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define N 5using namespace STD;intA[n];Long LongB[n];floatC[n];DoubleD[n];void_int () {puts("");puts("int:");puts("");memsetA0x7f,sizeofa);printf("%d\n", a[0]);memsetA0x80,sizeofa);printf("%d\n", a[0]);memsetA0x81,sizeofa);printf("%d\n", a[0]);puts("");memsetA0XBF,sizeofa);printf("%d%d\n", a[0],a[0]*2);memsetA0xc0,sizeofa);printf("%d%d\n", a[0],a[0]*2);memsetA0xc1,sizeofa);printf("%d%d\n", a[0],a[0]*2);puts("");memsetA0x3e,sizeofa);printf("%d%d\n", a[0],a[0]*2);memsetA0x3f,sizeofa);printf("%d%d\n", a[0],a[0]*2);memsetA0x40,sizeofa);printf("%d%d\n", a[0],a[0]*2);puts("");memsetA0x7e,sizeofa);printf("%d\n", a[0]);memsetA0x7f,sizeofa);printf("%d\n", a[0]);memsetA0x80,sizeofa);printf("%d\n", a[0]);}void_long () {puts("");puts(" Long Long:");puts("");memset(b,0x7f,sizeofb);printf("%i64d\n", b[0]);memset(b,0x80,sizeofb);printf("%i64d\n", b[0]);memset(b,0x81,sizeofb);printf("%i64d\n", b[0]);puts("");memset(b,0XBF,sizeofb);printf("%i64d%i64d\n", b[0],b[0]*2);memset(b,0xc0,sizeofb);printf("%i64d%i64d\n", b[0],b[0]*2);memset(b,0xc1,sizeofb);printf("%i64d%i64d\n", b[0],b[0]*2);puts("");memset(b,0x3e,sizeofb);printf("%i64d%i64d\n", b[0],b[0]*2);memset(b,0x3f,sizeofb);printf("%i64d%i64d\n", b[0],b[0]*2);memset(b,0x40,sizeofb);printf("%i64d%i64d\n", b[0],b[0]*2);puts("");memset(b,0x7e,sizeofb);printf("%i64d\n", b[0]);memset(b,0x7f,sizeofb);printf("%i64d\n", b[0]);memset(b,0x80,sizeofb);printf("%i64d\n", b[0]);}void_float () {puts("");puts("float:");puts("");memsetC0xfd,sizeofc);printf("%f\n", c[0]);memsetC0xFE,sizeofc);printf("%f\n", c[0]);memsetC0xFF,sizeofc);printf("%f\n", c[0]);puts("");memsetC0xCD,sizeofc);printf("%f%f\n", c[0],c[0]*2);memsetC0xce,sizeofc);printf("%f%f\n", c[0],c[0]*2);memsetC0XCF,sizeofc);printf("%f%f\n", c[0],c[0]*2);puts("");memsetC0x4e,sizeofc);printf("%f%f\n", c[0],c[0]*2);memsetC0x4f,sizeofc);printf("%f%f\n", c[0],c[0]*2);memsetC0x50,sizeofc);printf("%f%f\n", c[0],c[0]*2);puts("");memsetC0x7e,sizeofc);printf("%.15f\n", c[0]);memsetC0x7f,sizeofc);printf("%.15f\n", c[0]);memsetC0x80,sizeofc);printf("%.15f\n", c[0]);}void_double () {puts("");puts("Double:");puts("");memset(d,0xfd,sizeofD);printf("%lf\n", d[0]);memset(d,0xFE,sizeofD);printf("%lf\n", d[0]);memset(d,0xFF,sizeofD);printf("%lf\n", d[0]);puts("");memset(d,0xc1,sizeofD);printf("%lf%lf\n", d[0],d[0]*2);memset(d,0xc2,sizeofD);printf("%lf%lf\n", d[0],d[0]*2);memset(d,0xc3,sizeofD);printf("%lf%lf\n", d[0],d[0]*2);puts("");memset(d,0x42,sizeofD);printf("%lf%lf\n", d[0],d[0]*2);memset(d,0x43,sizeofD);printf("%lf%lf\n", d[0],d[0]*2);memset(d,0x44,sizeofD);printf("%lf%lf\n", d[0],d[0]*2);puts("");memset(d,0x7e,sizeofD);printf("%lf\n", d[0]);memset(d,0x7f,sizeofD);printf("%lf\n", d[0]);memset(d,0x80,sizeofD);printf("%lf\n", d[0]);}intMain () {_int ();    _long ();    _float (); _double ();}

"Self-use" memset for int, long long, float, double extremum how Clear

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.