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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:13:45+00:00 2026-06-11T04:13:45+00:00

I have a config file which includes some factors I want to use for

  • 0

I have a config file which includes some factors I want to use for calculations.

public class Config {

  public static final double factor = 67/300; // ~0,2233...

}

Im accessing the factors like this:

public class Calculate {

  public static calc() {
    ...
    result *= Config.factor;
    ...

When I do that Config.factor equals 0, so my result is 0, too. I don’t have that problem if I set the factor to 0.2233, but that wouldn’t be as accurate. Why doesn’t setting it to 67/300 work?

  • 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-06-11T04:13:46+00:00Added an answer on June 11, 2026 at 4:13 am

    Try this:

    public static final double factor = 67/300d;
    

    The problem is that 67 and 300 are integer literals, so the division ends up being an integer, which is 0. The d at the end of the number makes it a double literal, so the result of 67/300d is a double.

    Note that in the previous code the double literal is 300d. You can also use 67d/300 or 67d/300d.

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

Sidebar

Related Questions

I have a python class which reads a config file using ConfigParser: Config file:
In my app, I have a simple ASCII file which stores some config info
I have a config file like package com.mypackage.referencedata.config; @Configuration @ComponentScan (com.mypackage.referencedata.*) public class ReferenceDataConfig
I have a very basic ccnet.config file, in which I am trying to use
I have a config.php file which has some constants and methods. I have a
I am using php and mysql. I have a Database config file (db-config.php) which
I have created a library which reads the app.config file and gets the type
I have a Web application (with a Web.config file), which will move through the
I have one custom config file. <Students> <student> <Detail Name=abc Class=1st Year> <add key=Main
I have a ini file which contains some sample values like: [Section1] Value1 =

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.