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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:22:38+00:00 2026-05-19T17:22:38+00:00

Seems simple question but I really suck at math and few examples online I’ve

  • 0

Seems simple question but I really suck at math and few examples online I’ve searched seems not working for me. (the result just return the same value as input etc)

For instance.. but its in C not Java
Round to Next .05 in C

So my goal is I have %.1f format float or double or big decimal and wanting to round it up to nearest .5

example:

1.3 --> 1.5
5.5 --> 5.5
2.4 --> 2.5
3.6 --> 4.0
7.9 --> 8.0

I tried following example but didn’t work 🙁 below just output 1.3 which is original value. I wanted it to be 1.5

public class tmp {

    public static void main(String[] args) {

      double foo = 1.3;

      double mid = 20 * foo;

      System.out.println("mid " + mid);

      double out = Math.ceil(mid);

      System.out.println("out after ceil " + out);

      System.out.printf("%.1f\n", out/20.0);
    }
}
  • 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-19T17:22:39+00:00Added an answer on May 19, 2026 at 5:22 pm

    Multiplying (and later dividing) by 2, not 20, should do the trick.

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

Sidebar

Related Questions

This seems like a really simple question but I haven't seen it answered anywhere.
This seems like a really simple question but somehow my Google-Fu failed me. What's
this seems like a really simple Question...but behold :) Geek name:string Laser geek_id:integer, power:integer
I have question that seems simple to you all but can't really get it.
I feel kind of silly asking this question as it seems really simple, but
I've got a really simple rails question here but I can't seem to find
Seems like a simple enough question but I can't seem to find the answer.
This seems to be an absurdly simple question but Google and Stack Overflow searches
This seems like a simple question, but I can't find it with the Stack
Now it seems like a really simple question and I may just be being

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.