From: Petter Fryklund <petter.fryklund@atero.se>
Subject: Re: Converting 64 bit float to record containing a record of one 32 bit integer and one 32 unsigned.
Date: Fri, 1 Dec 2017 04:32:38 -0800 (PST)
Date: 2017-12-01T04:32:38-08:00 [thread overview]
Message-ID: <2eaeaeea-0d91-43bf-8da3-1cb6f3c9117b@googlegroups.com> (raw)
In-Reply-To: <ovrele$fbo$1@dont-email.me>
Den fredag 1 december 2017 kl. 12:33:04 UTC+1 skrev Jeffrey R. Carter:
> On 12/01/2017 10:24 AM, Petter Fryklund wrote:
> > Please don't waste time!
> >
> > This was actually fun to implement! I created my own float2hex. This was possible since I could work with the Integer part only (Float'Floor) looping (taking the remainder after division by 16 and filling a string(1..15) backwards). Might be a coding practice for learners.
>
> From your 1st msg, I thought you were trying to extract the bit image of the
> float type into your record, which is trivial. However, it appears you're trying
> to do the equivalent of Integer (F) for a value that won't fit in your largest
> integer types.
>
> Yes, producing an image (in any base) is an interesting exercise. Why limit
> yourself to hex, though? Why not create an Image function that takes an optional
> Base parameter and produces the image in any base that you know how to represent?
>
> PragmARC.Unbounded_Integers, for example, produces images in any base in 2 ..36.
> In fact, you could accomplish the same thing by using an instance of
> Ada.Text_IO.Float_IO to produce an image of the floor of your value in base 10
> without an exponent, trim off the decimal point and everything after it, pass
> this to the Value function of Unbounded_Integers, and pass that to Image with
> Base => 16.
>
> https://github.com/jrcarter/PragmARC
>
> --
> Jeff Carter
> "I'm a kike, a yid, a heebie, a hook nose! I'm Kosher,
> Mum! I'm a Red Sea pedestrian, and proud of it!"
> Monty Python's Life of Brian
> 77
Well since not in academia, I must solve the problems at hand, not invent new ones ;-) This solves the problem of storing a 64 bit value received from outside in a float value containing seconds since Jan 1st 1970. Old ObjectAda doesn't have 64 bit integers. Going via a hex value made the last part, storing the Integer value in the most significant part and the Natural value in the least significantpart, easy.
next prev parent reply other threads:[~2017-12-01 12:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-01 6:38 Converting 64 bit float to record containing a record of one 32 bit integer and one 32 unsigned Petter Fryklund
2017-12-01 9:24 ` Petter Fryklund
2017-12-01 11:33 ` Jeffrey R. Carter
2017-12-01 12:32 ` Petter Fryklund [this message]
2017-12-01 16:39 ` Jeffrey R. Carter
2017-12-05 7:55 ` Petter Fryklund
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox