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 X-Received: by 10.107.30.11 with SMTP id e11mr6409906ioe.87.1512131559166; Fri, 01 Dec 2017 04:32:39 -0800 (PST) X-Received: by 10.157.39.197 with SMTP id c63mr267814otb.11.1512131559008; Fri, 01 Dec 2017 04:32:39 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.am4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!i6no595248itb.0!news-out.google.com!193ni956iti.0!nntp.google.com!i6no595244itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 1 Dec 2017 04:32:38 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=136.163.203.6; posting-account=g0yTkgoAAADdZGEYyZahxGlO3EkjH0Wv NNTP-Posting-Host: 136.163.203.6 References: <6488d44e-1ea7-47bc-8d01-ab571677b6a5@googlegroups.com> <6002f2d2-71da-4cc1-aae4-c1de68ef2694@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <2eaeaeea-0d91-43bf-8da3-1cb6f3c9117b@googlegroups.com> Subject: Re: Converting 64 bit float to record containing a record of one 32 bit integer and one 32 unsigned. From: Petter Fryklund Injection-Date: Fri, 01 Dec 2017 12:32:39 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 3397 X-Received-Body-CRC: 3229936467 Xref: reader02.eternal-september.org comp.lang.ada:49297 Date: 2017-12-01T04:32:38-08:00 List-Id: 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! > >=20 > > This was actually fun to implement! I created my own float2hex. This wa= s possible since I could work with the Integer part only (Float'Floor) loop= ing (taking the remainder after division by 16 and filling a string(1..15) = backwards). Might be a coding practice for learners. >=20 > From your 1st msg, I thought you were trying to extract the bit image of= the=20 > float type into your record, which is trivial. However, it appears you're= trying=20 > to do the equivalent of Integer (F) for a value that won't fit in your la= rgest=20 > integer types. >=20 > Yes, producing an image (in any base) is an interesting exercise. Why lim= it=20 > yourself to hex, though? Why not create an Image function that takes an o= ptional=20 > Base parameter and produces the image in any base that you know how to re= present? >=20 > PragmARC.Unbounded_Integers, for example, produces images in any base in = 2 ..36.=20 > In fact, you could accomplish the same thing by using an instance of=20 > Ada.Text_IO.Float_IO to produce an image of the floor of your value in ba= se 10=20 > without an exponent, trim off the decimal point and everything after it, = pass=20 > this to the Value function of Unbounded_Integers, and pass that to Image = with=20 > Base =3D> 16. >=20 > https://github.com/jrcarter/PragmARC >=20 > --=20 > 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 n= ew 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 Object= Ada 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 val= ue in the least significantpart, easy.