Multiplication 1 cycle and division 3 cycles with Floating point Unit?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Multiplication 1 cycle and division 3 cycles with Floating point Unit?

ソリューションへジャンプ
1,874件の閲覧回数
BasePointer
Contributor II

Hi,

 

Yesterday I have watched a video related with kinetis introduction on freescale web page.

 

There, they said floating point multiplication is 1 cycle, and floating point division is 3 cycles (something like that, I couldn’t remember the exact values now)

 

As I know, floating point multiplication and division should be same. Aren’t they? I mean dividing a value into 4 is same operation with multiplying it with 0.25? Why are their cycles different?

 

Thanks.

 

0 件の賞賛
返信
1 解決策
1,585件の閲覧回数
kef
Specialist I

No, FP multiplication and division aren't the same. You can replace /4 by *0.25, but you can do this only for known constants. You (and not your MCU) calculate reciprocal of divider and use multiplication instead of division. But who will calculate reciprocal of variable to replace division with multiplication? Also, C compiler is not allowed to optimize any FP operation, like replacing division by constant with multiplication by constant, since these can produce not exactly the same results.

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
1,586件の閲覧回数
kef
Specialist I

No, FP multiplication and division aren't the same. You can replace /4 by *0.25, but you can do this only for known constants. You (and not your MCU) calculate reciprocal of divider and use multiplication instead of division. But who will calculate reciprocal of variable to replace division with multiplication? Also, C compiler is not allowed to optimize any FP operation, like replacing division by constant with multiplication by constant, since these can produce not exactly the same results.

0 件の賞賛
返信
1,585件の閲覧回数
BasePointer
Contributor II

Yes you are right, thanks :smileyhappy:

0 件の賞賛
返信