delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/12/17:06:35

Message-ID: <37D83B2C.3A14225B@lycosmail.com>
Date: Thu, 09 Sep 1999 18:56:44 -0400
From: Adam Schrotenboer <ajschrotenboer AT lycosmail DOT com>
X-Mailer: Mozilla 4.6 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: 64 bit integer, putc and double.
References: <7r8ied$9im$1 AT news7 DOT svr DOT pol DOT co DOT uk>
Reply-To: djgpp AT delorie DOT com

I don't know if you have already received some replies to this question, and if
you have, they're probably more useful.

Anyway, to answer #1, the easy one, yes. It does.GCC has support for 64-bit
integers (long long. long int is the same as int(32 bit), and a a short is a
16-bit int [But you probably already knew that]) on most platforms (Linux x86 and
DOS x86 included).

For #2 I should say that I have never been very successful w/ file I/O in C (Yes,
I know that I should learn it. In the course on C++ I took, we got very behind
and never got to chapter 9 (File I/O). I haven't had much time since then to
buckle down and figure it out).

Anyway, why not try a union w/ a float and (long) int for floats, and a union w/
double and long long int for your double. That should be the simplest, and then
there are no problems w/ casting pointers, or dealing w/ pointers at all.

Hope this all helps, and hope that none of it obfuscates. Good luck and happy
coding!!!

Tom Morton wrote:

> I have 2 questions:
>
> 1. Does djgpp support 64-bit integers?
>
> 2. I need to store float and double variables in a binary savegame file.
> How is this done using getc/putc. My plan is to shove the address of
> the float into a long integer pointer and then write the float to the
> file as if it is an 32-bit integer. Saving doubles would involve saving
> the first and second 32-bits as seperate chunks. (Doubles are 64-bit, right?)
> Does that sound correct? I realise that to save long integers I will have to
> break them into bytes first.
>
> --
> Yikes Station: Frontier Elite 2 Website
> http://www.yikesstation.freeserve.co.uk/frontier/yikes.htm
>
> Tom 'Moretom' Morton


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019