14 events
when toggle format what by license comment
Aug 27, 2022 at 22:56 comment added jwezorek Just like to add that another reason to use floats is when you are working with a library that uses floats extensively. The big example here being OpenCV. OpenCV defines things like its convex hull routine where the float point/double point distinction does not even effect the algorithm only for float points.
Nov 23, 2021 at 16:40 comment added Hulk @Milan shader languages such as OpenGL GLSL often use float types for color representation and corrdinate systems, e.g. for vertex- and geometry shaders. Many GPUs provide hardware support for that.
Nov 19, 2021 at 20:41 comment added Milan @rwong Images have pixel locations in integer format and so do the pixel values, right? Higher resolution images have more pixels but their locations would still be in integer. Same way, pixel values can have an 8-bit resolution, 16-bit, or more but that still be in integer values, correct? Please do correct me if I'm mistaken here. Thank you in advance!
Nov 19, 2021 at 20:35 comment added Milan @user949300 which GPUs do better with floats? Also, by any chance do you know why? Thank you in advance!
Dec 31, 2017 at 7:42 comment added Francis Cugler ... Also the effects of caching should play a large role in the decision to choose one type over another. If the order of magnitude of floating point arithmetic operations is low, then double should be fine for both memory consumption, caching and the speed time complexity of the function - operation, once the magnitude of operations exceeds a limit that is dependent on the architecture, OS, language - compiler then float should be considered. There is always a tradeoff between one or the other.
Dec 31, 2017 at 7:33 comment added Francis Cugler IMHO it all depends on the application and the target of accepted accuracy. For example: if one is working on a 3D Graphics Rendering Engine where you are operating on millions or billions of vertices in a 3D Cartesian graph, then it is more efficient to use float with some loss of precision for performance gain. On the other hand if precision is of a higher importance such as in an application that works with sub atomic particles or astronomy type situations and the efficiency of performance is not as high of a priority then by all means use a double.
Feb 7, 2015 at 13:20 comment added raptortech97 It should be noted that ops on long double are often extremely slow, as much as 5x, because they generally have to be implemented in software
Nov 17, 2014 at 22:00 comment added rwong I endorse this answer with one additional advice: When one is operating with RGB values for display, it is acceptable to use float (and occasionally half-precision) because neither the human eye, the display, or the color system has that many bits of precision. This advice is applicable for say OpenGL etc. This additional advice does not apply to medical images, which have more strict precision requirements.
Sep 9, 2014 at 19:03 comment added greggo @PatriciaShanahan - 'performance problem related to..' A good example is if you are planning to use SSE2 or similar vector instructions, you can do 4 ops/vector in float (vs 2 per double) which can give a significant speed improvement (half as many ops and half as much data to read & write). This can significantly lower the threshold where using floats becomes attractive, and worth the trouble to sort out the numeric issues.
Aug 19, 2014 at 16:57 comment added user949300 I'd use floats for millions of numbers, not 1000s. Also, some GPUs do better with floats, in that specialized case use floats. Else, as you say, use doubles.
Mar 8, 2013 at 15:27 vote accept Jakub Zaverka
Feb 28, 2013 at 16:30 comment added zzzzBov As an addendum, if you need compatibility with other systems, it can be advantageous to use the same data types.
Feb 28, 2013 at 15:35 comment added Patricia Shanahan I would probably not consider float for a few thousand values unless there were a performance problem related to floating point caching and data transfer. There is usually a substantial cost to doing the analysis to show that float is precise enough.
Feb 28, 2013 at 10:50 history answered Bart van Ingen Schenau CC BY-SA 3.0