user3757605
user3757605

Reputation: 442

Node JavaScript - decimal string to integer

I am using a Node.js module which returns a value that I need to convert into a string or a 64-bit integer. The returned value looks like this:

{ low: 214107458, high: 17825793, unsigned: true }

The documentation states that it is something called decimal string. I am not sure what that means. The value I want is suppose to look like this: 76561198174373186

How can I convert it?

This is the module that I get the value from: https://github.com/seishun/node-steam

To be specific, this code: https://github.com/seishun/node-steam/blob/84cc4f870b8da4755ba057acff336a093891458f/lib/handlers/friends/index.js

This is the module that I need to send the converted value to: https://github.com/Lwatt/node-steam-userinfo/blob/master/index.js

My code:

steamFriends.on('friendMsg', function(steamID, message, type) {
    if(type != Steam.EChatEntryType.ChatMsg) return;
    steamuserinfo.getUserInfo(steamID, function(error, data){
        if(error) throw error;
        var datadec = JSON.parse(JSON.stringify(data.response)); //This returns an empty array because steamID is in incorrect form.
        console.log(steamID); //Output: { low: 214107458, high: 17825793, unsigned: true }
    });
});

Upvotes: 3

Views: 473

Answers (1)

Ilya
Ilya

Reputation: 5557

I am not sure what that means

It works like this: 76561198174373186 = 17825793 * 10^32 + 214107458

NB for converting to a "76561198174373186" string, the easiest way would be to use a 64 bits integers supporting lib, G.I.Y.F.

Upvotes: 2

Related Questions