Skip to content
Advertisement

JavaScript C Style Type Cast From Signed To Unsigned

how to type cast a number in javascript?

a = (unsigned int)atoi(arg1);
b = (unsigned int)atoi(arg2);

Assuming that a and b can be signed.

I want to convert a 4 byte signed integer into a 4 byte unsigned integer.

I know there is no such thing as type casting or signed/unsigned in javascript. I am looking for an easy to understand algorithm.

Advertisement

Answer

You can try a = arg1>>>0, but I’m not sure it will do what you are looking for.

See this question for more details.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement