Giter Club home page Giter Club logo

Comments (3)

bgreni avatar bgreni commented on July 22, 2024 3

This appears to be another symptom of the issue described in #2860

from mojo.

Ryul0rd avatar Ryul0rd commented on July 22, 2024 3

I think this is definitely a bug since people trying to cast ints to floats or floats to ints would not reasonably expect their values to first be implicitly cast to bools.

from mojo.

f-saez avatar f-saez commented on July 22, 2024

I guess the correct way to change types is to do like this :

def main():
    var y:Int = 1337
    var y0 = Int32(y)
    var y1 = y0.cast[DType.float32]()
    var y2 = y1.cast[DType.uint32]()
    print("y :",y)
    print("y0 :",y0)
    print("y1 :",y1)
    print("y2 :",y2)
    y0 = -1
    y2 = y0.cast[DType.uint32]()
    print("y2 :",y2)

because it seems to give expected answers

y : 1337
y0 : 1337
y1 : 1337.0
y2 : 1337
y2 : 4294967295

so, maybe not a bug but a misunderstanding.

If someone could confirm that's the correct way to do it, I'll be happy close the bug.

from mojo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.