From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
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 12:33:02 +0100
Date: 2017-12-01T12:33:02+01:00 [thread overview]
Message-ID: <ovrele$fbo$1@dont-email.me> (raw)
In-Reply-To: <6002f2d2-71da-4cc1-aae4-c1de68ef2694@googlegroups.com>
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
next prev parent reply other threads:[~2017-12-01 11:33 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 [this message]
2017-12-01 12:32 ` Petter Fryklund
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