Float, double, long double in CAD

Rhino OpenNurbs mainly use double for floating point numbers. Other kernels like CGAL allows to choose between float, double and long double. OpenGL and shaders mostly use float 32 bit representations.

When developing the core of Rhino how do you decide which type do you choose, is it for speed, precision? If you would have chosen float what issues of precision you would have faced?

I don’t know about Rhino specifically and their motivations, but generally I read somewhere that on modern hardware double-precision arithmetic is just as fast as single-precision because it’s optimized that way. A double thus offers roughly 15 decimal digits for the same price as around 7 digits for floats. And on top of that compilers might promote floats to doubles introducing extra conversions during compilation.
Modern C++ also defaults to doubles perhaps because of this.

This is new I did not know that! I am wondering why python stays at float 32 bit precision.

I don’t think that is the case.

  1. Floating-Point Numbers (float):
    Python’s float type typically uses 64-bit double-precision floating-point numbers, adhering to the IEEE 754 standard. This provides approximately 15-17 decimal digits of precision. It is important to note that due to the binary nature of floating-point representation, some decimal numbers cannot be represented exactly, leading to potential minor inaccuracies.

So in all cased we have 64 bit?

What happens at rhino opengl vizualization level, do you cast f64 to f32 ?

GPUs almost always run at 32bit floating point precision for display purposes. I believe some general purpose GPU computing technologies like cuda may support 64bit, but when it comes to the calculations involved in computing colors for pixels it is 32bit. That stands for OpenGL, Direct3D, Metal and Vulkan. Some of the older opengl routines allows you to send doubles to a function, but those doubles were converted to floats for the real calculations on the GPU. This is why we have to do special massaging of data to try and support display of objects far from origin.

Thank you very much to clarify this confusion…