This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How can I convert from unsigned int to double so that I can use the sqrt function?

Hi guys,

this may seem like a newbie type of question but i'm really stumped on this one. I want to use the sqrt() function from math.h on two variables which are unsigned int.

if i do:

unsigned int Id, Iq;
double temp;
Id = ///some function call
temp = (double)Id;

and assuming Id contains say 0x2700, after executing the 3rd line, temp = 0, not 9984 as it should. Does anyone know how I can convert from unsinged int to double besides the way I've tried.

thanks a lot.

Nick

Parents
  • "I guess I can't rely much on the simulator."

    I can't see why that should be the case.

    Does the code actually function correctly on the simulator?

    Could this just be an optimisation issue, where you're trying to watch a variable that's been optimised away?
    Have you tried stepping at the assembler level in the simulator.

Reply
  • "I guess I can't rely much on the simulator."

    I can't see why that should be the case.

    Does the code actually function correctly on the simulator?

    Could this just be an optimisation issue, where you're trying to watch a variable that's been optimised away?
    Have you tried stepping at the assembler level in the simulator.

Children
No data