Can this be used to generate unsigned ints? #6

Closed
opened 2016-03-16 23:48:53 +00:00 by tnrich · 1 comment
tnrich commented 2016-03-16 23:48:53 +00:00 (Migrated from github.com)

Hey there,

I'm currently using your module like so:

    var bsonObjectid = require('bson-objectid');
    var CRC32 = require('crc-32')

    var MySchemaId = bsonObjectid().str
    var sales_order_id = CRC32.str(MySchemaId)

But I'm noticing sometimes the sales_order_id is negative. Is there a way to get the CRC32 module to only output unique positive values?

Thanks so much,
Thomas

Hey there, I'm currently using your module like so: ``` js var bsonObjectid = require('bson-objectid'); var CRC32 = require('crc-32') var MySchemaId = bsonObjectid().str var sales_order_id = CRC32.str(MySchemaId) ``` But I'm noticing sometimes the sales_order_id is negative. Is there a way to get the CRC32 module to only output unique positive values? Thanks so much, Thomas
SheetJSDev commented 2016-04-07 16:50:48 +00:00 (Migrated from github.com)

For performance reasons we default to using signed integers. However, if you need an unsigned integer, the best way is to convert using the unsigned right shift operator:

CRC32.str(MySchemaId) >>> 0
For performance reasons we default to using signed integers. However, if you need an unsigned integer, the best way is to convert using the unsigned right shift operator: ``` CRC32.str(MySchemaId) >>> 0 ```
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/js-crc32#6
No description provided.