Can we not have one integer type in c that can grow like in js as required and become bigint if too big?
I thought js "integers" are just floating point numbers?
41–50 of 280 posts
Can we not have one integer type in c that can grow like in js as required and become bigint if too big?
I thought js "integers" are just floating point numbers?
Got unrootable old (but still fully working) phone there, might try to play with it.
This kind of issue is the reason why some more modern languages like Rust or Go do not have implicit narrowing conversions. For instance, on Rust, trying to simply pass an usize (Rust's equivalent of size_t) to a function which expects an i32 (Rust's equivalent of int) will not compile; the programmer has to write "size as i32" (Rust's equivalent of "(int) size"), which makes it explicit that it might truncate the va…
While some folks aren't too fussed about warnings like this, those folks generally aren't writing secure code like kernels. I'm very surprised that kind of conversion was permitted in the code.
Can we not have one integer type in c that can grow like in js as required and become bigint if too big?
A newly designed OS kernel could perhaps take on this kind of feature. This would be the kind of OS that could be formally verified and would be willing to pay that runtime cost for arbitrary precision.
Anyone knows how to try the PoC ( https://www.openwall.com/lists/oss-security/2021/07/20/1/1 ) ? For me it crashes into the fork_userns:177 PS: don't need to downvote. Sometimes managers want you to prove that there's a need to patch. It's dumb but it's what it is
This kind of issue is the reason why some more modern languages like Rust or Go do not have implicit narrowing conversions. For instance, on Rust, trying to simply pass an usize (Rust's equivalent of size_t) to a function which expects an i32 (Rust's equivalent of int) will not compile; the programmer has to write "size as i32" (Rust's equivalent of "(int) size"), which makes it explicit that it might truncate the va…
> Some Rust developers argue that even "size as i32" should be avoided, and "size.try_into()" should be used instead, since it forces the programmer to treat an overflow explicitly at runtime, instead of silently wrapping. It's important to still have the option for efficient truncating semantics, though; some software (e.g. emulators) needs to chunk large integers into 2/4/8 smaller ones, and rotation + truncating a…
Then safety is free...
Can we not have one integer type in c that can grow like in js as required and become bigint if too big?
Try this:
>> const x = 288230376151711740;
>> x == x + 1
true
Or this: >> 2\*1024
Infinity
JS doesn't even have integers. It only has floats. JS is by far the worst language I know of when it comes to integer support.If you want a better example of arbitrary precision integers, try Python, for example.
Can we not have one integer type in c that can grow like in js as required and become bigint if too big?
>that can grow like in js I thought js "integers" are just floating point numbers?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
This kind of issue is the reason why some more modern languages like Rust or Go do not have implicit narrowing conversions. For instance, on Rust, trying to simply pass an usize (Rust's equivalent of size_t) to a function which expects an i32 (Rust's equivalent of int) will not compile; the programmer has to write "size as i32" (Rust's equivalent of "(int) size"), which makes it explicit that it might truncate the va…
> Unfortunately, this size_t is also passed to functions whose size argument is an int (a signed 32-bit integer), not a size_t. Is this the type of things that could be caught by a linter or strict compilation rules? This seems to be to be a failure of the type system.
AFAIK most compilers by default will output a warning in this case.