3

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 }
    });
});
5
  • 2
    Javascript does not have 64-bit integers. There are some libraries out there that might help , for example developer.mozilla.org/en-US/docs/Mozilla/js-ctypes/… Commented Jan 4, 2016 at 13:13
  • decimal means 10based number and string is still string. This is probably a hack / workaround for lacking 64 bit integer support as John already mentioned. Commented Jan 4, 2016 at 13:18
  • I see. However string is fine too. Is there a way to convert this to one string that looks like this "76561198174373186" or should I use that library? Commented Jan 4, 2016 at 13:29
  • done some formatting. But include the link of documentation, citations from documentation, and name of the module that you are using. Commented Jan 4, 2016 at 13:30
  • I have added the modules and the snippet from my code. Commented Jan 4, 2016 at 14:04

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.