
28 Nov
2012
28 Nov
'12
8:02 a.m.
Say I have functions like so: code: -------- circleRadians = 2 * pi radius = (/ circleRadians) -------- My question: each time I call radius, will a division operation be performed? Is there anything to be gained, following the old adage that multiplication is more efficient than division in hardware, from something like: code: -------- radius = (* (1 / circleRadians)) -------- ...imagining that the compiler (or runtime graph reduction mechanism) will transform (1 / circleRadians) into a single number (s) only once, and use (* s) in all applications of radius? -- frigidcode.com