Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript C Style Type Cast From Signed To Unsigned

Tags:

javascript

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.

like image 952
Matthias Avatar asked Feb 15 '13 08:02

Matthias


1 Answers

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.

like image 126
Vatev Avatar answered Sep 19 '22 18:09

Vatev