Re: Integer arithmetic vs double precision arithmetic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/26/06, Shriramana Sharma <samjnaa@xxxxxxxxx> 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
-
: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux