From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

NumericTextBoxDouble shows -0 instead of 0

Solved!
Go to solution

There is something weird happening: I put NumericTextBoxDouble at form, set its value to 0, and it shows -0. It obviously should be 0.

 

Measurement Studio 2013 / VS 2010/2013

0 Kudos
Message 1 of 4
(4,956 Views)

Trying to run your example on my machine results in an upgrade of the NationalInstruments.Common library from version 13.5.40.173 to 13.5.40.190.

 

Regardless if i update the project or not, i cannot reproduce the issue you describe. I am pretty sure that the project uses the .190 version in any case as the .173 isn't installed on my machine.

Did you run the update service on your MStudio installation?

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 4
(4,940 Views)
Solution
Accepted by eugenem

This is a known issue with an update made to a Measurement Studio dependency that was shipped in a recent driver release. This has been fixed internally, and should be available soon.

 

Until that fix is available, as a workaround you can use a custom value formatter to wrap the existing formatter and correct the incorrect negative zero display:

 

    numericTextBox.ValueFormatter = new NegativeZeroCorrection( );

 

    ...

 

    public sealed class NegativeZeroCorrection : ValueFormatter {
        private readonly ValueFormatter _inner;

        public NegativeZeroCorrection( ValueFormatter inner = null ) {
            _inner = inner ?? new GeneralValueFormatter();
        }

        protected override string FormatCore<TData>( TData value, ValuePresenterArgs args ) {
            string result = _inner.Format<TData>( value, args );
            if( result == "-0" )
                result = "0";
            return result;
        }

        public override TData Parse<TData>( string value, ValuePresenterArgs args ) {
            return _inner.Parse<TData>( value, args );
        }

        public override bool TryParse<TData>( string value, ValuePresenterArgs args, out TData parsedValue ) {
            return _inner.TryParse<TData>( value, args, out parsedValue );
        }

        protected override Freezable CreateInstanceCore( ) {
            return new NegativeZeroCorrection( );
        }
    }

~ Paul H
0 Kudos
Message 3 of 4
(4,935 Views)

Just wanted to let you know this issue (#519251) was fixed in the Measurement Studio 2015 release.

~ Paul H
0 Kudos
Message 4 of 4
(4,426 Views)