Skip to content
Advertisement

multiprocessing.Value doesn’t store float correctly

I try to asign a float to the multiprocessing.Value shared ctype as follows:

JavaScript

However, the float stored in multiprocessing.Value is != the input float:

JavaScript

Whats the problem here?

EDIT: Found the solution (see answers) However, I do not understand, why a “double” is the correct type here and not a “float”. If someone can elaborate on that and include the solution, I will mark it as the correct answer.

Advertisement

Answer

Python floats are double-precision floats, or what other languages would call double‘s. That is why you need to use 'd': 'f' does not correspond to the precision level python uses for float‘s

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement