GithubHelp home page GithubHelp logo

int256's People

Contributors

benaadams avatar fixxxedpoint avatar lukaszrozmej avatar micahzoltu avatar olegjakushkin avatar rubo avatar scooletz avatar tanishqjasoria avatar tkstanczak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

int256's Issues

UInt256.cs ToLittleEndian method issue

At first let's look to contructor from byte[] in litle endian mode:

                    u0 = BinaryPrimitives.ReadUInt64LittleEndian(bytes.Slice(0, 8));
                    u1 = BinaryPrimitives.ReadUInt64LittleEndian(bytes.Slice(8, 8));
                    u2 = BinaryPrimitives.ReadUInt64LittleEndian(bytes.Slice(16, 8));
                    u3 = BinaryPrimitives.ReadUInt64LittleEndian(bytes.Slice(24, 8));

And now to ToLittleEndian itself:

                BinaryPrimitives.WriteUInt64LittleEndian(target.Slice(0, 8), u3);
                BinaryPrimitives.WriteUInt64LittleEndian(target.Slice(8, 8), u2);
                BinaryPrimitives.WriteUInt64LittleEndian(target.Slice(16, 8), u1);
                BinaryPrimitives.WriteUInt64LittleEndian(target.Slice(24, 8), u0);

In constuctor we read u0 from first 8 bytes, but in ToLittleEndian we write in first 8 bytes u3 value.
So if we trying make UInt256 from ToLittleEndian we get different value.

        [Test]
        public virtual void CheckToLittleEndian()
        {
            var v = UInt256.Parse("0xfb5764948f29b38f6f4456eff35caab6741b5a19292862ff4d376a570cd473d7");
            var v2 = new UInt256(v.ToLittleEndian());
            v2.Should().Be(v);
        }

Parsing from hex numbers

When NM client parses something like a Dictionary from JSON where input keys look like: "0x0000000000000000000000000000000000000000000000000000000000000000" we currently fail.

This leads to dirty hacks like re-implementing dictionary parser like they do here with explicit (UInt256)BigInteger.Parse(skey.Substring(2), NumberStyles.HexNumber); in it.

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.