Make decimal point to whole numbers

kah

I have textBox1 and it contains number 10. I need to get that number 10 to double with decimal point. My current code is:

variables.myNum = double.Parse(textBox1);

I have declared myNum in variables class:

public static double myNum;

With that code I get that number 10 to double. The problem is that I need to have decimal point too so I would like to have "10.". If I write to textBox1 "10." it doesn't work.

EDIT: .ToString("0.00") gives the decimal point to whole numbers but it also gives those two zeros which I do not want. Only point is needed with whole numbers.

EDIT: First I have:

10
10.5
10.58
10.589

I would like to have: (note dot after 1st ten)

10.
10.5
10.58
10.589

With .ToString("0.00") I can get:

10.00
10.50
10.58
10.58

But I don't want those extra zeros at the end. Only dot and numbers which are not zero.

Manfred Radlwimmer

You could just add a ., if the output doesn't contain one already.

public static string ToGCodeNumber(double number, int digits)
{
    // rounding (optional)
    double number = Math.Round(number, digits);

    // result with or without '.'
    string intermediateResult = roundedNumber.ToString(CultureInfo.InvariantCulture);
    if(!intermediateResult.Contains(".")
        intermediateResult += ".";

    // final result with a guaranteed '.'  
    return intermediateResult;
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Make decimal point to whole numbers

From Dev

Excel number format adds decimal point for whole numbers

From Dev

Sorting an array of decimal & whole numbers

From Dev

Get all whole and decimal numbers from string

From Dev

Convert floating point numbers to decimal numbers

From Dev

How to make a textBox accept only Numbers and just one decimal point in Windows 8

From Dev

How to make a xaml textbox in silverlight accept only numbers with maximum one decimal point precision

From Dev

Make calculations with hexadecimal/decimal numbers

From Dev

Difference between inputing whole numbers and decimal numbers in C

From Dev

Selecting floating point numbers in decimal form

From Dev

Conversion of decimal floating point numbers to binary and back

From Dev

In a unix timestamp should there be numbers after a decimal point?

From Dev

how to subtract numbers with decimal point in php

From Dev

Aligning numbers at decimal point angular ui grid

From Dev

Formatting Numbers So They Align On Decimal Point

From Dev

storing the numbers after the decimal point into a variable in MySQL

From Dev

Getting output of 2 numbers after the decimal point

From Dev

Conversion of decimal floating point numbers to binary and back

From Dev

Searching for numbers with a comma as a decimal point in an array

From Dev

Bash (Yad) using floating point numbers instead of whole numbers

From Dev

awk - match positive whole numbers and floating point numbers only

From Dev

Ruby big decimal with 2 numbers after the decimal point

From Dev

Pasting decimal numbers in excel / comma and point decimal separator

From Dev

How to make TextView with decimal numbers Android Studio

From Dev

How to make a list of Binary numbers a list of Dotted Decimal Numbers?

From Dev

Remove Decimal Point in a Dataframe with both Numbers and String Using Python

From Dev

How to find shortest decimal number between two floating point numbers

From Dev

Comparing version numbers with more than one decimal point in Excel VBA

From Dev

Checking if input is a float and has exactly 2 numbers after the decimal point

Related Related

  1. 1

    Make decimal point to whole numbers

  2. 2

    Excel number format adds decimal point for whole numbers

  3. 3

    Sorting an array of decimal & whole numbers

  4. 4

    Get all whole and decimal numbers from string

  5. 5

    Convert floating point numbers to decimal numbers

  6. 6

    How to make a textBox accept only Numbers and just one decimal point in Windows 8

  7. 7

    How to make a xaml textbox in silverlight accept only numbers with maximum one decimal point precision

  8. 8

    Make calculations with hexadecimal/decimal numbers

  9. 9

    Difference between inputing whole numbers and decimal numbers in C

  10. 10

    Selecting floating point numbers in decimal form

  11. 11

    Conversion of decimal floating point numbers to binary and back

  12. 12

    In a unix timestamp should there be numbers after a decimal point?

  13. 13

    how to subtract numbers with decimal point in php

  14. 14

    Aligning numbers at decimal point angular ui grid

  15. 15

    Formatting Numbers So They Align On Decimal Point

  16. 16

    storing the numbers after the decimal point into a variable in MySQL

  17. 17

    Getting output of 2 numbers after the decimal point

  18. 18

    Conversion of decimal floating point numbers to binary and back

  19. 19

    Searching for numbers with a comma as a decimal point in an array

  20. 20

    Bash (Yad) using floating point numbers instead of whole numbers

  21. 21

    awk - match positive whole numbers and floating point numbers only

  22. 22

    Ruby big decimal with 2 numbers after the decimal point

  23. 23

    Pasting decimal numbers in excel / comma and point decimal separator

  24. 24

    How to make TextView with decimal numbers Android Studio

  25. 25

    How to make a list of Binary numbers a list of Dotted Decimal Numbers?

  26. 26

    Remove Decimal Point in a Dataframe with both Numbers and String Using Python

  27. 27

    How to find shortest decimal number between two floating point numbers

  28. 28

    Comparing version numbers with more than one decimal point in Excel VBA

  29. 29

    Checking if input is a float and has exactly 2 numbers after the decimal point

HotTag

Archive