From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada 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 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <6488d44e-1ea7-47bc-8d01-ab571677b6a5@googlegroups.com> <6002f2d2-71da-4cc1-aae4-c1de68ef2694@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 1 Dec 2017 11:33:02 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="3fa0733b19f5c5b9c1c4a97a632b97d4"; logging-data="15736"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+2gHj5K6kAQaAaqps7KTyL0jEug8+8pPw=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 In-Reply-To: <6002f2d2-71da-4cc1-aae4-c1de68ef2694@googlegroups.com> Content-Language: en-US Cancel-Lock: sha1:1eyBdYhjr2iDNo+310qpremX97Q= Xref: reader02.eternal-september.org comp.lang.ada:49296 Date: 2017-12-01T12:33:02+01:00 List-Id: 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