From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Mario Lang Newsgroups: gmane.emacs.devel Subject: Re: osc-insert-float32 Date: Tue, 17 Dec 2019 22:10:56 +0100 Message-ID: <87h81y8xpb.fsf@blind.guru> References: <8736diakx0.fsf@blind.guru> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="66641"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 17 22:11:35 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ihK7y-000HE2-33 for ged-emacs-devel@m.gmane.org; Tue, 17 Dec 2019 22:11:34 +0100 Original-Received: from localhost ([::1]:46300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihK7w-0000Z9-Pw for ged-emacs-devel@m.gmane.org; Tue, 17 Dec 2019 16:11:32 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50787) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihK7T-00008w-4h for emacs-devel@gnu.org; Tue, 17 Dec 2019 16:11:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihK7S-0002sE-6J for emacs-devel@gnu.org; Tue, 17 Dec 2019 16:11:03 -0500 Original-Received: from [2001:41d0:a:14ab::1] (port=45492 helo=ns3035380.ip-37-187-20.eu) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ihK7S-0002rb-12 for emacs-devel@gnu.org; Tue, 17 Dec 2019 16:11:02 -0500 Original-Received: by ns3035380.ip-37-187-20.eu (Postfix, from userid 110) id CD9B7351; Tue, 17 Dec 2019 21:10:59 +0000 (UTC) Original-Received: from x1.blind.guru (84-115-55-45.cable.dynamic.surfer.at [84.115.55.45]) by ns3035380.ip-37-187-20.eu (Postfix) with ESMTPSA id F1A7734A; Tue, 17 Dec 2019 21:10:57 +0000 (UTC) Original-Received: by x1.blind.guru (Postfix, from userid 1000) id DD9C7E81828; Tue, 17 Dec 2019 22:10:56 +0100 (CET) In-Reply-To: (Stefan Monnier's message of "Tue, 17 Dec 2019 14:02:18 -0500") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:41d0:a:14ab::1 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:243444 Archived-At: Stefan Monnier writes: > Mario Lang [2019-12-17 19:04:11] wrote: > >> 14 years ago, I wrote this beast to be able to send IEEE floating point >> values over the network (Open Sound Control). Reading it today, I am >> actually surprised I was driven enough to get this working. I am >> wondering, is there a better way to achieve this today? > > There's `frexp` to extract the exponent and the mantissa. Oh, I didn't know that either. However, it looks like `frexp' isn't very useful when it comes to encoding to binary. It is a bit too long ago that I researched the binary32 encoding and wrote the code in question, but from diving back into the matter, it looks like the mantissa in binary format is in the 1.0..2.0 range. frexp gives 0.5..1.0, so the exponent is also off for what binary needs. I guess I could just adjust those values, but I dont really know what I am doing here, so I'll leave it as it is for now. Thanks for the food for thought though. --=20 CYa, =E2=A1=8D=E2=A0=81=E2=A0=97=E2=A0=8A=E2=A0=95