How to get the correct precision of fraction from hdlcoder?

Hi,
I came across the difference result value from hdlcoder testbench as the below,
### Begin TestBench generation.
a =
     0
a =
     0
a =
     0
the function code below
%%Function
function result=test(u)
dx=1.71;
u1 = u / 10000;
result= u1/dx ;
end
end
the test code below
clear
clc
u=3000;
[a]=test(u)
u=4;
[a]=test(u)
u=500;
[a]=test(u)
But correct calculation is below,
a =
0.1754
a =
2.3392e-04
a =
0.0292
How do I get value correctly?

2 commentaires

Thanks I've solved that problem. please close this case.

Réponses (0)

Cette question est clôturée.

Tags

Clôturé :

le 1 Fév 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by