I would like to store in a variable the mantisssa of a double
I have post a code to get the binary representation of a double : click here
What should I chan
A stringify tokenizing approach:
#include <string.h>
#include <stdio.h>
long double example=(-10000.0/7.0);
long long ldoubtollmant(long double num)
{ char stackdump1[101]={'\0'};
char *dump1=&stackdump1[0];
char stackdump2[101]={'\0'};
char *dump2=&stackdump2[0];
snprintf(dump1,100,"%.15Le",num);
char *next1=dump1;
next1=strtok(dump1,"e");
char *next2=NULL;
strtok_r(next1,".",&next2);
snprintf(dump2,100,"%s%s",dump1,next2);
return atoll(dump2);}
short int ldoubtoshexp(long double num)
{ char stackdump1[101]={'\0'};
char *dump1=&stackdump1[0];
snprintf(dump1,100,"%.15Le",num);
char *next1=NULL;
strtok_r(dump1,"e",&next1);
return (short int)atoi(next1);}
int main(int argc,char *argv[])
{ printf("\n%lld",ldoubtollmant(example));
printf("\n%hd",ldoubtoshexp(example));}