MessageboardHard- & Softwareaka pipelined

Sort:     printview reply
Author: Message:
fezdmwqf
Hohlbratze
908 Posts
registered: 26.10.2013
30.10.2013, 13:18 email offline quote 

Should I use double or float
In a nutshell, although double offer higher precision in their representation, for some sort of arithmetical it would give a lot more error. The "right" options are: use as much accuracy as you need but not countless choose the right algorithm. 80bits and 128bits floating), this should be taken into account as well. In practice, you'll be able to hardly see any diverse in speed they are generally natives to equipment anyway.
There are about three floating point types: float, double, along with long double. The kind of double provides at least as much precision because float, and the kind long double provides at least as much accuracy as double.
Therefore, all three can be the identical size in memory.
Presence of an FPU. Not all CPUs have FPUs and sometimes the floating position types are copied and sometimes the sailing point types are just not supported.
FPU Structure. The IA32's FPU is 80bit internally 32 bit and Sixty-four bit floats are expanded to 80bit on load and reduced on store. Additionally, there are SIMD which can do a number of 32bit floats or a pair of 64bit floats in simultaneous. Use of SIMD is not identified in the standard so that it would require a compiler that will does more complex analysis to determine if SIMD works extremely well, or requires the using special functions (collections or intrinsics). The result of the 80bit internal file format is that you can get a little different results depending on how some of the data is saved to be able to RAM (thus, shedding precision). For this reason, compilers never optimise floating stage code particularly effectively.
Memory bandwidth. If a double requires more storage than a flow,Parajumpers jakker, then it will take longer to read the data. This is the naive answer. On a modern IA32, it all depends on where the data is via. If it's in L1 cache, the load is negligible provided the data comes from a single cache range. If it spans multiple cache line you will find there's small overhead. If it is from L2, it takes a while longer, if it's in RAM then it's longer still and finally, whether it's on disk it is a huge time. So the choice of float as well as double is significantly less important than the means the data is used. If you need to do a small formula on lots of sequential data, a small info type is preferable. Doing a lot of calculations on a small files set would allow you to have bigger data sorts with any significant effect. If you're accessing the information very randomly, then your choice of data dimension is unimportant data is filled in pages Per cache lines. Thus even if you only need a byte from RAM, you can get 32 bytes transferred (this is extremely dependant on the architecture of the system). On top of all of this, the CPU/FPU could be superscalar (aka pipelined). So, although a load may take a number of cycles, the CPU/FPU might be busy doing another thing (a multiply as an example) that hides the burden time to a degree.
The conventional does not enforce just about any particular format regarding floating point ideals.
If you have a specification, then that will guide you to the optimal option. Otherwise, it's down to experience as to what to work with.
Perhaps surprisingly, it can be double and not flow that is the "normal" floatingpoint type in D (and C++). The standard numbers functions such as sin and log take doubles as justifications, and return doubles. A normal floatingpoint literal, as when you write 3.14 in your program, has the type increase. Not float.
On typical modern computer systems, doubles will be just like fast as glides,parajumper, or even faster, so performance is usually not just a factor to consider, even for large calculations. (The ones would have to be significant calculations, or functionality shouldn't even enter your mind. My severalyearsold computer adds five hundred thousand doubles in one subsequent.)
You should be very careful for those who have double and move in your application. I'd a bug due to that in the past. One part of the code was utilizing float while the other code was utilizing double. Copying increase to float and then flow to double might cause precision error that may have big affect. In my case, it was a chemical factory. with luck , it didn't have extraordinary consequences
I think that it must be because of this kind of irritate that the Ariane 6 explode has exploded a few years ago!!!
Consider the type to be used for a variable
It depends highly on the CPU the most obvious tradeoffs are between accuracy and memory. Together with GBs of RAM, storage is not much of a problem, so it's generally preferable to use doubles.
For performance, it depends very on the CPU. drifts will usually get better overall performance than doubles over a 32 bit equipment. On 64 touch, doubles are sometimes quicker, since it is (usually) the particular native size. Still, what will matter much more than your choice of information types is whether or not it is possible to take advantage of SIMD instructions on the processor.
Sort:     printview reply
To reply to this topic you have to be registered and logged in!

register now
log in