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
  • Nick,

    I've tried to duplicate you problem here and I can't seem to get it to fail at all running under the simulator. Since you didn't provide a complete example, I had to invent one and maybe that's the problem.

    Also, I ran everything under the Keil simulator. I'm not sure what a "Keil/FS2 Simulator" is.

    If you can provide me with a complete example that fails it would help us find any problem in simulation.

    FYI, I use the simulator on a daily basis and rarely find a problem with it.

    Jon

Reply
  • Nick,

    I've tried to duplicate you problem here and I can't seem to get it to fail at all running under the simulator. Since you didn't provide a complete example, I had to invent one and maybe that's the problem.

    Also, I ran everything under the Keil simulator. I'm not sure what a "Keil/FS2 Simulator" is.

    If you can provide me with a complete example that fails it would help us find any problem in simulation.

    FYI, I use the simulator on a daily basis and rarely find a problem with it.

    Jon

Children
  • Hi Jon and All,

    We are using a third party Debugger called FS2 by First Silicon Solutions. It is designed to work with the Keil environment. It comes with its own simulator. Since we use that debugger to do board level debug, we also used its simulator to do the simulations. So it is not the Keil Simulator, but a third party simulator, which is designed to work within the Keil IDE. That could explain the problem I was having with simulating my code, but its all resolved now. So again, it was a third party simulator I was using, not the Keil simulator, and I indicated that when I said we're using the Keil/FS2 Simulator.

    thanks
    -Nick

  • Perhaps you need to alert these First Silicon Solutions guys that maybe there is a bug in their simulator?