How to use 64 bit integer in 16 Bit Dos ?

I

Imayam

Hi .!
This is my first post to this community..! I am trying to use
64 bit data in 16 Bit dos.Here i have a Borland C 3.1 Compiler in which
i have data types

int = 2 byte
long = 4 byte
float = 4 byte
double =8 byte
long double =80 byte

Here i was trying to use double ..but i couldn,t read it from
the buffer i don't know why ?

Is there is any good idea to use 64 bit integer data type in dos 16..?

Thanks in Advance ..
Imayam
 
K

Keith Thompson

Imayam said:
This is my first post to this community..! I am trying to use
64 bit data in 16 Bit dos.Here i have a Borland C 3.1 Compiler in which
i have data types

int = 2 byte
long = 4 byte
float = 4 byte
double =8 byte
long double =80 byte

If you want a 64-bit data type, you could try char[8] (I presume
CHAR_BIT==8), but I doubt that that's what you had in mind.
Here i was trying to use double ..but i couldn,t read it from
the buffer i don't know why ?

I don't know why either. Nobody can possibly guess why if you don't
show us the code.
Is there is any good idea to use 64 bit integer data type in dos 16..?

Oh, you want a 64-bit *integer* type. double is a floating-point
type. Type long long is guaranteed to be at least 64 bits, but it
might not be supported by your compiler.
 
I

Imayam

Keith said:
Imayam said:
This is my first post to this community..! I am trying to use
64 bit data in 16 Bit dos.Here i have a Borland C 3.1 Compiler in which
i have data types

int = 2 byte
long = 4 byte
float = 4 byte
double =8 byte
long double =80 byte

If you want a 64-bit data type, you could try char[8] (I presume
CHAR_BIT==8), but I doubt that that's what you had in mind.
Here i was trying to use double ..but i couldn,t read it from
the buffer i don't know why ?

I don't know why either. Nobody can possibly guess why if you don't
show us the code.
Is there is any good idea to use 64 bit integer data type in dos 16..?

Oh, you want a 64-bit *integer* type. double is a floating-point
type. Type long long is guaranteed to be at least 64 bits, but it
might not be supported by your compiler.


Hi ..Thanks you ..thanks a lot..:)
I don't know why either. Nobody can possibly guess why if you don't
show us the code.

Sorry ....I am not writing any code as of now but my basic need is
this ,i want to handle 64 bit data so I just written some test
program..that has nthg to do i have given my code below

memcpy(&Test1,&Buf[30],8); //I am trying to copy 64 bit data from
buffer

val1 = my_atof(Test1,8); //I am using function which will
convert this to double
printf("\n val1=%lf",val1);


////////////////////////////////////
double my_atof(char *src, int len)
{
double result = 0;
char tmp,str[32],str1[32],*endptr;
int i,j;

memset(str1,NULL,32);
for (i = 0,j=len; i <=len; i++,j--)
{
tmp =(int) src [j];
itoa(tmp,str,10);
strcat(str1,str);
}

str1[32]='\0';
printf("\n STRc = %s ",str1);
result = strtod(str1,&endptr);
printf("\n RESLUT = %lf",result);
return result;
}

//////////////////////////////////

Actually I was trying to perform above function it is also not working
for me...

Consider the memory area ..It is Little Endian
0x30 : C0 19 00 00 00 00 00 00 00 00 00 00 00 00 00
-----------------------------------

if I copy the value to my variable using -->
memcpy(&Test1,&Buf[30],8);
i wil get Test1[0] = 0xC0
Test1[1]=0x19;
Test1[1]=0x00; etc....

i calling function ...........

val1 = my_atof(Test1,8);
{
tmp =(int) src [j]; //In first routine i will get
0,0,0,0,0,0,25,192
itoa(tmp,str,10); //I have to convert it to string Other wise it
will take this as
//Ascii Value...so my str
contains ="192"

strcat(str1,str); //Concatinating the string
}

at the End of the Loop i have string ---> 25192
result = strtod(str1,&endptr);
if i convert this into double -------------> i Will get 25192.00000


but the Required Output is -----------> 6592.
More over it is time consuming function. So i want to handle 64 Bit
Data Type effectively .

so How can i achive this ..??

Regards
Imayam
 
M

Mark McIntyre

Consider the memory area ..It is Little Endian
0x30 : C0 19 00 00 00 00 00 00 00 00 00 00 00 00 00 ....
at the End of the Loop i have string ---> 25192 ....
but the Required Output is -----------> 6592.

This isn't a C question, its all about algorithms and data storage.

Sit down with a pencil and paper, and work out how your platform is
storing the data, so that you can work out how to read it correctly.

THEN write an algorithm to perform that read.

For more advice, I'd suggest comp.programming or one of the DOS
groups.

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top