Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j5KT4-0001fN-SC for pgsql-hackers@arkaria.postgresql.org; Sat, 22 Feb 2020 02:24:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j5KT3-0007Kt-CB for pgsql-hackers@arkaria.postgresql.org; Sat, 22 Feb 2020 02:24:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j5KT2-0007Kl-VJ for pgsql-hackers@lists.postgresql.org; Sat, 22 Feb 2020 02:24:33 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j5KSv-0006bD-Qm for pgsql-hackers@postgresql.org; Sat, 22 Feb 2020 02:24:31 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id E120921FC5; Fri, 21 Feb 2020 21:24:24 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 21 Feb 2020 21:24:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=begriffs.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=mesmtp; bh=tG1G63Ea3EyYruMAN29Ff4dD bHLIPhTZ5Yp1YS3rJhg=; b=LypVFQjOHNXi78OvoN+6Lg1li8EA2+VTG7YZCmiU uT+ukk6gclZPv4SistKHJUmt3qZZfEO0Wkep0mSYpTx/lL7CjR7YIj0sD5LKvkDx mAVvrSd/n8iifXNNgCSvBbIqOIB2Cn8uWX++1gpgLqJpqtdNc0+zpRSd61eTTPT0 V7Q= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=tG1G63 Ea3EyYruMAN29Ff4dDbHLIPhTZ5Yp1YS3rJhg=; b=yz07RAXGFivxKL0XZqYCwx DQ0Z8gSLqmg7PXKJOPhSsjsLp8Q+3Y65jhA7VtPFU843qAq3RQv6QxOzyqQpmJqu HjbML4Mf/nQeGHAV263sFOhhaduDG6MLYAHVOWCo/jf7t4YWMQFbcnFJ1wmxnQoG VDTNNppE8VsEN1hx8QFePVxPoASm9ssf7/H23/gCkcrYrWv+WJ4C24D17yd4XFdN KGJqoEmZY5IcmMqAdhDC7pVFlf0G7t1qHGvWvr2voGpznPOpF42/1hIv7sX2aFZN takmmfPa4cBPos6eoEXV4z+ZruMB/+CSliwz3gLSdTVPRTJiDvrg5eUDkvH1HDdQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrkeehgdegiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtuggjfgesthdtre dttderjeenucfhrhhomheplfhovgcupfgvlhhsohhnuceojhhovgessggvghhrihhffhhs rdgtohhmqeenucffohhmrghinhepsggvghhrihhffhhsrdgtohhmpdhgihhthhhusgdrtg homhenucfkphepvddtjedrudehfedrudeirdejkeenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpehjohgvsegsvghgrhhifhhfshdrtghomh X-ME-Proxy: Received: from fastmail.com (207-153-16-78.fttp.usinternet.com [207.153.16.78]) by mail.messagingengine.com (Postfix) with ESMTPA id 385B13060BE4; Fri, 21 Feb 2020 21:24:24 -0500 (EST) Date: Fri, 21 Feb 2020 20:24:23 -0600 From: Joe Nelson To: Jeff Davis Cc: pgsql-hackers@postgresql.org Subject: Re: POC: rational number type (fractions) Message-ID: <20200222022423.GH42864@begriffs.com> References: <20200208042554.GE42864@begriffs.com> <80df7e765063cf044a483a751d7171017f697a31.camel@j-davis.com> <20200222012447.GG42864@begriffs.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200222012447.GG42864@begriffs.com> User-Agent: Mutt/1.12.1 (2019-06-15) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Joe Nelson wrote: > where the denominator is made positive whenever possible (not possible > when it's -INT_MAX). (I meant INT_MIN rather than -INT_MAX.) Another more-than-one-way-to-do-it task is converting a float to a fraction. I translated John Kennedy's method [0] to C, but Github user adegert sent an alternative [1] that matches the way the CPython implementation works. 0: https://begriffs.com/pdf/dec2frac.pdf 1: https://github.com/begriffs/pg_rational/pull/13