Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8681853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:36:58+00:00 2026-06-12T21:36:58+00:00

I created a GUI which inputs a value number into another program and stores

  • 0

I created a GUI which inputs a value number into another program and stores them in tags. I have a weird conversion problem. When I input 8.5 I get back a string 8.500000000000000… so I use the TryParse and the Double.ToString() method to get around this issue. But the bizarre part is that when I try with 6.9 the string becomes 6.9000000005367431600000.I use 2 dll which might be the cause of this problem. I’ve read this Decimals explanation but I don’t understand how this can be fix my problem. How to get around with this conversion issue?

My Conversion method

    private bool TryWrite()
            {
// Read() returns a string(which represents int,double, float or string) read from another application
                string Oldcopy = _inTouchWrapper.Read(tagNameBox.Text);
// Write() Write my input number into the application stored in a specific tag
                _inTouchWrapper.Write(tagNameBox.Text, ValueBox.Text);
//OldCopy is to input back the old copy is the Write (new copy) cannot be performed
                string newCopy = _inTouchWrapper.Read(tagNameBox.Text);

                if (ValueBox.Text == Double.Parse(newCopy).ToString())
                {
                    return true;
                }
                else
                {
                    _inTouchWrapper.Write(tagNameBox.Text, Oldcopy);
                    return false;
                }
            }

More explanation about the software/and my code. The software has tags ex: Alarm1, TimeString…
Each tag has a type (int, real(a float), string) and a value. This value depends on the type. I cannot input 5.6 if the tag type is int. So I created this method which verifies is the input value can indeed be added in the software. How it works: I input a value in the software, read it back and if the added value matches with the read value, I indeed input it. Else, I input back the oldCopy.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T21:36:59+00:00Added an answer on June 12, 2026 at 9:36 pm

    It seems that string “6.9” is not directly converted to double. If is first converted to float and then casted to double. Here is an example:

    var f = float.Parse("6.9");
    var d = (double)f;
    System.Diagnostics.Debug.WriteLine(d.ToString()); //6.90000009536743
    

    PS: Why you not have the same issue with ‘8.5’ is that it can exactly be represented in binary form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a GUI for starting a Thread which does something very simple.
I have a class (simulation) which creates an instance of another class (GUI). Inside
I have created a GUI which requires .dll files in order to work. Here
I have a Windows program that has a GUI which also uses a command
I have a class which extends JFrame and forms the GUI of my program.
I have created a simple GUI engine which I plan to use in a
I'm trying to create a responsive gui, which basically means that I have an
I have created a GUI that will setup the pivot table. For example, I
I have created my GUI using wxGlade and it looks fine in the display.
I have a windows application which has a complex GUI that I would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.