Comments (5)
Smaller repro:
fn main():
print(int(UInt8(128))) # prints -128
It's very curious that the following runs fine:
fn main():
var n = UInt8(128)
print(n) # prints 128
print(int(n)) # prints 128
from mojo.
Smaller repro:
fn main(): print(int(UInt8(128))) # prints -128
Similarly, running:
var a: UInt32 = 129
print(int(a.cast[DType.uint8]()))
in the REPL returns 129
.
Running:
def main():
var a: UInt32 = 129
print(int(a.cast[DType.uint8]()))
main()
In the REPL returns -127
from mojo.
Just tested on nightly and behaviour is identical.
Nightly version: mojo 2024.6.1705 (79838f00)
from mojo.
The 1
is caused by implicit conversion. UInt32(...)
doesn't do what you think it does.
from mojo.
So just to be clear:
The var
vs alias
differences seem to only appear when reading a value from a table.
So there might be two issues: the table one and the int()
one.
from mojo.
Related Issues (20)
- Implement arithmetic operators for `UInt`
- [BUG] math/numeric functions weird behavior with float16 types HOT 6
- [BUG] question about writing to file HOT 5
- [BUG] Cannot materialize a capturing closure
- [Docs] the "random" module should not be imported by default HOT 2
- [BUG] Index out of bound with nested list literals HOT 1
- [Feature Request] Allow __get_item__ calls to use a mix of colon slices and integers
- [BUG] Program Crash on generating simple data. HOT 1
- [BUG] errors on install HOT 3
- [Feature Request] [proposal] Fast but unsafe version of atol
- [BUG] Install Issue--Infected file warning (from Intego/Virusbarrier) HOT 2
- [BUG] Install Issue: Failed to run Script (mojo format) HOT 4
- [BUG] crash when attempting to use MAC mps when wrapping PyTorch
- [BUG] Possible SIMD[DType.bool, n] tested for truth in the stdlib where n > 1 HOT 7
- [BUG] Parser crash when a overload for a trait method is added
- [BUG] `Tensor` initialised from a list with wrong type shows weird behaviour
- [BUG] Parser crash when `moveinit` with wrong argument convention is defined while using `@value` HOT 1
- [BUG] LSP & Mojo crashes when using Python.evaluate in a certain way HOT 4
- [Feature Request] [stdlib] [proposal] Add comp time `SIMD` range constructor
- [Feature Request] [stdlib] Add `assert_aborts()` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mojo.