Issue
I have come across this example from the numpydoc:
np.promote_types('i4', 'S8')
dtype('S11')
Basically, I cant understand the following:
An i4 takes 4 bytes and an S8 takes 8 bytes. So why - in terms of memory - do I need a S11 to accomodate both types? I would have expected S8 as the result.
Solution
S8 is a character string. Therefore the relevant case to think about when choosing a dtype to accomodate both i4 and S8 is representing the longest number possible in i4 as a character string.
To represent -2,147,483,648 as a string you need 11 characters. That's why you get S11 as the result.
Answered By - JonasV
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.