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

  • SEARCH
  • Home
  • 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 6471551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:14:13+00:00 2026-05-25T06:14:13+00:00

I have a double and I want to format it with the following rules:

  • 0

I have a double and I want to format it with the following rules:

  1. If there are no decimal places show just the number (see 100 example below)
  2. If there are any decimal places show 2 decimal places

So, as a few examples:

100 --> 100  
99.958443534 --> 99.96  
99.1 -> 99.10  
  • 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-05-25T06:14:14+00:00Added an answer on May 25, 2026 at 6:14 am

    You can use:

    decimal a = 99.949999999M;
    
    Math.Round(a, 2);  // Returns 99.95
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to format a double number that always have n digits
I have a double number like 1,01 and I want to make it 2
i have a double, the decimal place isn't fix (8-?) i want to fix
Hi I have the following object: Hashtable<Object, Double> and I want to find the
Say I have a number, double, or NSNumber, 3.333333 I want that to turn
I want to split data from file which have the following format: {[(1;1;2),(5;1;2),(5;1;1)],[(1;3;2),(5;3;2),(5;1;2)]} And
I have a double value. I want to format this value in the format
I have a decimal number, say 1234.500. I want to display it as 1,234.5.
I have double number in a format like 34.123456789 . How can I change
I have the following format: SOLEXA3_1:3:5:1473:616/1 gi|7367913151|ref|NC_007367.1| 100.00 23 0 0 27 49 3404561

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.