linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Steve Graegert" <graegerts@gmail.com>
To: linux-c-programming@vger.kernel.org
Subject: Re: Integer arithmetic vs double precision arithmetic
Date: Sun, 26 Mar 2006 16:12:02 +0000	[thread overview]
Message-ID: <6a00c8d50603260812q1ebddc26uae1c9b70bbe0d46e@mail.gmail.com> (raw)
In-Reply-To: <200603262044.37068.samjnaa@gmail.com>

On 3/26/06, Shriramana Sharma <samjnaa@gmail.com> wrote:
> I am trying to work out whether to use an integer or a double for my
> internal
> storage variable of a class meant to store a time.
>
> Qt uses an unsigned integer with millisecond being the best precision, but I
> am wondering, why I should lose the extra digits of precision that I could
> get if I used a double.
>
> Is there a marked increase in computing speed if integer arithmetic is used
> compared to double precision?

It depends: every modern average CPU can do floating point arithmetics
at least as fast as simple integer arithmetics (sometimes even
faster).   The emphasis here lies on "can".  If the compiler has
difficulties generating code for the FPU of a specific target platform
it will default to floating point library calls causing real
performance penalties.

Why do you consider doubles to store time values?

	\Steve

  reply	other threads:[~2006-03-26 16:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-26 15:14 Integer arithmetic vs double precision arithmetic Shriramana Sharma
2006-03-26 16:12 ` Steve Graegert [this message]
2006-03-26 16:24   ` Shriramana Sharma
2006-03-26 21:03     ` Glynn Clements
2006-03-26 23:35       ` Shriramana Sharma
2006-03-27  1:02         ` Glynn Clements
2006-03-27  8:32           ` Shriramana Sharma
2006-03-27 17:13             ` Glynn Clements
2006-03-26 16:12 ` Glynn Clements

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6a00c8d50603260812q1ebddc26uae1c9b70bbe0d46e@mail.gmail.com \
    --to=graegerts@gmail.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).