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 5993879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:44:18+00:00 2026-05-22T23:44:18+00:00

Some Math people please help, I want to convert using only Math. Function. (Pow,

  • 0

Some Math people please help, I want to convert using only Math. Function. (Pow, Floor……etc) with only single statement as possile, not using if else to check if the 5fifth digits after decimals from 1-4 or 6-9 .

  • i want to convert 5 digits after decimal to 5 digits after decimal with the following rules , alway 5 and 0 at the end.

Rule 1:

double number1 = 1.2345* 
if( * from 1 to 4)
   number1 ==> 1.23455 
if ( * from 6 to 9)
  number1  ==> 1.23460 

Rule 2:

double number2 = 1.2345* 
if( * from 1 to 4)
   number2 ==> 1.23450 

if ( * from 6 to 9)
  number2  ==> 1.23455 

I Came up with answer for Rule 1, but it need to 2 statement, I wonder if it can be done with only 1 statement

number1 = Math.Floor((number1 + 0.00005) * 20000) / 20000 - 0.00005;
number1 = Math.Floor((number1 + 0.00005) * 20000) / 20000 ;

Thanks

  • 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-22T23:44:19+00:00Added an answer on May 22, 2026 at 11:44 pm

    For rule #1:

    var y = (int)((x - 0.00001) * 20000) / 20000.0 + 0.00005;
    

    Result:

    1.23450 => 1.23450
    1.23451 => 1.23455
    1.23452 => 1.23455
    1.23453 => 1.23455
    1.23454 => 1.23455
    1.23455 => 1.23455
    1.23456 => 1.23460
    1.23457 => 1.23460
    1.23458 => 1.23460
    1.23459 => 1.23460
    1.23460 => 1.23460
    

    For rule #2:

    var y = (int)(x * 20000) / 20000.0;
    

    Result:

    1.23450 => 1.23450
    1.23451 => 1.23450
    1.23452 => 1.23450
    1.23453 => 1.23450
    1.23454 => 1.23450
    1.23455 => 1.23455
    1.23456 => 1.23455
    1.23457 => 1.23455
    1.23458 => 1.23455
    1.23459 => 1.23455
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to convert a string into a double and after doing some math
I'm trying to do some date math in Visual Basic. The NETWORKDAYS function in
I want to define an structure, where some math constants would be stored. Here
I'm implementing some math types and I want to optimize the operators to minimize
I am performing some math in an SQL select statement but the number is
I'm drawing some lines in cocos2d (using handy ccDrawLine), nothing fancy, but i want
I heard of some Math.random() but I'm not sure about using it correctly. Number
There is the situation - i made some math modelling app on C#(WPF), showing
I'm in the situation where i need to do some math related stuff in
I'm building a Flash project where it needs to handle some math, like an

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.