[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Hey /g/, I'm reading through C++ Primer and a tip states
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 7
Thread images: 1
File: 5646456.jpg (74 KB, 900x518) Image search: [Google]
5646456.jpg
74 KB, 900x518
Hey /g/, I'm reading through C++ Primer and a tip states that I should use double instead of float most of the time since float usually isn't precise enough and the difference in performance is minimal.

Is this mainly true?
>>
ya
>>
Float is usually precise enough but the performance difference is minimal so always use double unless you have a reason not to.
>>
Really depends. I find the instances where you need double precision floats are kinda limited, depending on your domain.

For most things general logic, string processing, data storage you're usually better served using integers.

For games, graphics, interactive stuff, the increased processing rate and memory savings of fp32 usually win over the increased precision of fp64.

For scientific computing, general calculations fp64 reigns supreme, although you're often even hitting precision limits with doubles there.
>>
>>53631640
> half precision = 10b fraction = ~3 decimal digits precision
> single precision = 23b fraction = ~7 decimal digits precision
> double precision = 52b fraction = ~16 decimal digits precision

vidya graphics can get away with single precision, most numerical simulation should use double.

on a modern x86_64 processor, you have an FPU designed to crunch through doubles as quickly as possible with negligible performance cost for most operations. multiplies and adds/subtracts are so cheap they're almost free, but things like division/reciprocals, square roots, trig functions, etc. can take dozens of cycles and DO take upwards of twice as long for doubles as for floats.

honestly you should just use double unless you know what you're doing well enough to be able to prove you can see and actually need the speed gain from using floats.
>>
>>53631640
Thanks for the insight /g/. I'll keep this in mind, it's just whenever I saw that comment I was wondering what programmers at /g/ thought about it.
>>
>>53631640
this is true, only if you have a 64bit processor driving a 64 bit OS.
Most modern processors are 64bit.
Thread replies: 7
Thread images: 1

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.