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

Fixes for issue #416 #933

Merged
merged 4 commits into from
Oct 23, 2018
Merged

Conversation

sharmavishnu
Copy link
Contributor

@sharmavishnu sharmavishnu commented Oct 21, 2018

Description

Fixed format generation for hexadecimal numbers that was causing issues with ToString("Xnn") calls.

Motivation and Context

For hexadecimal numbers, there is no concept of signed/unsigned. Also, floats are not represented in hexadecimal formatting like normal int/long.

How Has This Been Tested?

Tested with the following code:

        //Integer test            
        Console.WriteLine("Min UInt32=" + UInt32.MinValue + ",as Hex=0x" + UInt32.MinValue.ToString("X16"));
        Console.WriteLine("Max UInt32=" + UInt32.MaxValue + ",as Hex=0x" + UInt32.MaxValue.ToString("X16"));
        Console.WriteLine("Min Int32=" + Int32.MinValue + ",as Hex=0x" + Int32.MinValue.ToString("X16"));
        Console.WriteLine("Max Int32=" + Int32.MaxValue + ",as Hex=0x" + Int32.MaxValue.ToString("X16"));
        
        //Float test
        Console.WriteLine("Min float=" + float.MinValue + ",as formatted=" + float.MinValue.ToString("f16"));
        Console.WriteLine("Max float=" + float.MaxValue + ",as formatted=" + float.MaxValue.ToString("f16"));
                     
        //long test
        Console.WriteLine("Min UInt64=" + UInt64.MinValue + ",as formatted=0x" + UInt64.MinValue.ToString("x16"));
        Console.WriteLine("Max UInt64=" + UInt64.MaxValue + ",as formatted=0x" + UInt64.MaxValue.ToString("x16"));
        Console.WriteLine("Min Int64=" + Int64.MinValue + ",as formatted=0x" + Int64.MinValue.ToString("x16"));
        Console.WriteLine("Max Int64=" + Int64.MaxValue + ",as formatted=0x" + Int64.MaxValue.ToString("x16"));

Screenshots

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Signed-off-by: @sharmavishnu

@nfbot
Copy link
Member

nfbot commented Oct 21, 2018

Hi @sharmavishnu,

I'm nanoFramework bot.
Thank you for your contribution!

A human will be reviewing it shortly. 😉

@CLAassistant
Copy link

CLAassistant commented Oct 21, 2018

CLA assistant check
All committers have signed the CLA.

@josesimoes josesimoes added Type: bug Area: Interpreter Everything related with the interpreter, execution engine and such labels Oct 21, 2018
Copy link
Member

@josesimoes josesimoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Thank you for looking into this. 👏
Let's wait on @MatthiasJentsch review and running all the others tests over this.

Copy link
Contributor

@MatthiasJentsch MatthiasJentsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed the else block. We don't need to check formatCh == 'X' here.

Beside that it looks good to me. Tests are also working. I've tested only on ESP32. Good work!

@josesimoes josesimoes merged commit 2437715 into nanoframework:develop Oct 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Interpreter Everything related with the interpreter, execution engine and such Type: bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ToString() causing hardfault
5 participants