43261

How to get short value using Double Function? [duplicate]

Question:

<blockquote>

<strong>Possible Duplicate:</strong><br /><a href="https://stackoverflow.com/questions/151005/create-excel-xls-and-xlsx-file-from-c-sharp" rel="nofollow">Create Excel (.XLS and .XLSX) file from C#</a><br /><a href="https://stackoverflow.com/questions/2129804/rounding-double-values-in-c-sharp" rel="nofollow">Rounding double values in C#</a>

</blockquote>

my double function generating values like this

56,365989365

i want just value like this 56,36 how to get this ?

Answer1:

Use Math.Round. The second argument is the number of places.

var x = Math.Round(56.365989365, 2);

Answer2:

If you want to trucate the value:

value *= 100; value = Math.Truncate(value); value /= 100;

If you want to round the value:

value = Math.round(value, 2);

Recommend

  • Ruby Multiple OR Evaluations For String Value
  • How can I read in multiple excel files in SPSS using a macro?
  • Send data to WPF singleton application from other process
  • Formula in Excel that references another Excel file based on cell reference
  • Excel Range in C# using interop.Excel. Range both empty and not empty?
  • Default CUDA addition rounding mode between cuda 5.0 and 7.5
  • Removing levels from data frame read from CSV file - R
  • add two double given wrong result
  • Floating-point number in Excel
  • View/Download Pdf Files in React - Router 4
  • Merge list of objects into consistent list based on common matching attribute in Python
  • why 0.1+0.2-0.3= 5.5511151231258E-17 in php [duplicate]
  • Insert records if not exist SQL Server 2005
  • Creating UDF with VSTO in Excel
  • VBA Dir function not working on Excel 2010
  • Unique Permutations - with exceptions
  • Outlook to Excel hyperlink issue
  • C# Excel interop - how to test if interop object is still working and performing a task?
  • Python cosine function precision [duplicate]
  • Cloud Code function running twice
  • Use of this Javascript
  • Linq Objects Group By & Sum
  • Convert array of 8 bytes to signed long in C++
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • How to format a variable of double type
  • Comma separated Values
  • Buffer size for converting unsigned long to string
  • Load html files in TinyMce
  • Error creating VM instance in Google Compute Engine
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • Hits per day in Google Big Query
  • Understanding cpu registers
  • coudnt use logback because of log4j
  • how does django model after text[] in postgresql [duplicate]
  • Recursive/Hierarchical Query Using Postgres
  • Running Map reduces the dimensions of the matrices
  • Binding checkboxes to object values in AngularJs
  • Net Present Value in Excel for Grouped Recurring CF
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?