From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Question about best practices with numerical functions
Date: Tue, 7 Jul 2020 00:23:06 +0200 [thread overview]
Message-ID: <re0888$13vl$1@gioia.aioe.org> (raw)
In-Reply-To: e7a79ce2-dfb8-4482-96fb-46e1fe81d801o@googlegroups.com
On 06/07/2020 19:02, Shark8 wrote:
> One way to do this would be to use fixed-point types:
> (1) Convert your input to the fixed-point that has a "good enough" delta for the precision you want.
> (2) Run the algorithm.
> (3) Convert back to your normal value-type.
> This assumes you're using floating-point or integers, but one nice thing about fixed-point is that it has a bounded error when dealing with operations, unlike floating-point. -- I remember some years ago seeing a bug report dealing with floating-point, where the particular error simply couldn't have happened with fixed-point.
Rounding error is bounded in both cases. Fixed-point has same error
regardless the values involved in the operations. Floating-point has
error depending on the values.
I would say that floating-point error would be roughly same for
addition, subtraction and multiplication, provided fixed-point does not
overflow. It will be hugely better for division.
Using fixed-point arithmetic has only sense for a few marginal cases of
rounding.
Furthermore converting many algorithms to fixed-point might turn quite
non-trivial as you will have to ensure absence of overflows and
underflows. Where floating-point computation just would lose some
precision, fixed-point will catastrophically fail.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2020-07-06 22:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-04 5:30 Question about best practices with numerical functions mockturtle
2020-07-04 7:50 ` Dmitry A. Kazakov
2020-07-04 10:45 ` Nasser M. Abbasi
2020-07-06 17:02 ` Shark8
2020-07-06 22:23 ` Dmitry A. Kazakov [this message]
2020-07-07 4:52 ` mockturtle
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox