I wonder whether there is a faster way (faster then the obvious one a=a*a) to square the content of a vector of floats. I remember that bit shifting could be used somehow, but I'm not sure whether this works for floats. Any suggestions on how to achieve this are welcome (perhaps with the code).
Thanks
onako
0
Newbie Poster
Recommended Answers
Jump to Postfloat a;
cin >> a;
a = a*a;well, this is the fastest way I am aware of, perhaps you could make it a tiiiiiiiiiiny bit faster with
a *= a;
but probably most compilers will optimise this anyway.Bit shifting is about integers, and you can't use …
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.