Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix BigInteger #433

Merged
merged 4 commits into from
Jan 16, 2021
Merged

Fix BigInteger #433

merged 4 commits into from
Jan 16, 2021

Conversation

shargon
Copy link
Member

@shargon shargon commented Jan 15, 2021

Fix #432 fix #431

@shargon shargon mentioned this pull request Jan 15, 2021
@shargon shargon marked this pull request as ready for review January 15, 2021 10:32
@shargon shargon requested a review from Tommo-L January 15, 2021 10:32
@chenzhitong
Copy link
Member

chenzhitong commented Jan 15, 2021

Fixed #432 👍

@cloud8little
Copy link
Contributor

@shargon you can add the UT in #434

@shargon shargon mentioned this pull request Jan 15, 2021
@shargon
Copy link
Member Author

shargon commented Jan 15, 2021

@cloud8little I think that it works but not for hex string, for hex string we should use Atoi, it's hard to convert System.String,System.Globalization.NumberStyles into our base argument

else if (src.tokenMethod == "System.Numerics.BigInteger System.Numerics.BigInteger::Parse(System.String,System.Globalization.NumberStyles)")
                {
                    ConvertPushNumber(10, null, to);        // Push Base
                    Convert1by1(VM.OpCode.SWAP, src, to);   // Swap arguments
                    Insert1(VM.OpCode.SYSCALL, "", to, BitConverter.GetBytes(ApplicationEngine.System_Binary_Atoi));
                    return 0;
                }

@cloud8little
Copy link
Contributor

cloud8little commented Jan 15, 2021

@shargon I know that this is implementation problem. but still it is very confusing, because we have

  1. (BigInteger)xx
  2. BigInteger.Parse()
  3. xx.ToBigInteger()

I find that ToBigInteger also work well for hex byte array.

        public static BigInteger testtoBigInteger()
        {
            return ((new byte[] { 0x00, 0x00, 0x8d, 0x49, 0xfd, 0x1a, 0x07 })).ToBigInteger();
        }
neo> invoke 0x3c49e708254d317a85adf34e6d34a265859ee049 testtoBigInteger []
Invoking script with: 'EMAfDBB0ZXN0dG9CaWdJbnRlZ2VyDBRJ4J6FZaI0bU7zrYV6MU0lCOdJPEFifVtS'
VM State: HALT
Gas Consumed: 0.0112428
Result Stack: [{"type":"Integer","value":"2000000000000000"}]
Relay tx(no|yes): no

@shargon
Copy link
Member Author

shargon commented Jan 16, 2021

@cloud8little I agree, please open a new issue in order to find a more user friendly way

@shargon shargon merged commit 3caea8f into neo-project:master Jan 16, 2021
@shargon shargon deleted the fix-big-integer branch January 16, 2021 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BigInteger.Zero cannot compile successfully BigInteger.Parse Issue
5 participants