Skip to content

Function to simulate int32 wrapping #53

@canny

Description

@canny

Please add a function that converts a float64 to a signed 32-bit integer, compatable with lsl. It would be equivilant to

in luau:


function bit32.s32(n: number)

    return (math.modf(n) + 0x8000_0000) % 0x1_0000_0000 - 0x8000_0000

end

in c:


double s32(double n) {

    return (double)(s32)n;

}

Code that dealt with integers >= 0x8000_0000 behave differently in lsl and luau, due to s32 wrapping. I imagine there's already a function like this for the lsl compiler, but exposing it to slua scripters would be helpful for converting old scripts

https://secondlife.canny.io/admin/board/slua-alpha/p/function-to-simulate-int32-wrapping

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions