Real simple, my code is:
import numpy as np
a = np.array([0.4, 0.3])
b = np.array([-0.15, 0.2])
print(np.dot(a,b))
The dot product of this should be 0, and instead i get:
3.3306690738754695e-18
>Solution :
For something like that i’d suggest just using the rounding function to however many decimals you got, or using this:
dotproduct=0
for a,b in zip(a,b):
dotproduct = dotproduct+a*b
print('Dot product is:', dotproduct)
Which does the dot product regardless of floats or integers.