MCPcopy Index your code
hub / github.com/Shopify/go-lua / ToUnsigned

Method ToUnsigned

lua.go:787–793  ·  view source on GitHub ↗

ToUnsigned converts the Lua value at index to a Go uint. The Lua value must be a number or a string convertible to a number. If the number is not an unsigned integer, it is truncated in some non-specified way. If the number is outside the range of uint, it is normalized to the remainder of its div

(index int)

Source from the content-addressed store, hash-verified

785//
786// http://www.lua.org/manual/5.2/manual.html#lua_tounsignedx
787func (l *State) ToUnsigned(index int) (uint, bool) {
788 if n, ok := l.toNumber(l.indexToValue(index)); ok {
789 const supUnsigned = float64(^uint32(0)) + 1
790 return uint(n - math.Floor(n/supUnsigned)*supUnsigned), true
791 }
792 return 0, false
793}
794
795// ToString converts the Lua value at index to a Go string. The Lua value
796// must also be a string or a number; otherwise the function returns

Callers 1

CheckUnsignedFunction · 0.80

Calls 2

toNumberMethod · 0.95
indexToValueMethod · 0.95

Tested by

no test coverage detected