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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:23:11+00:00 2026-05-27T14:23:11+00:00

I happen to come across some similar kind of programming styles mostly when there

  • 0

I happen to come across some similar kind of programming styles mostly when there is an Float or Double operations.

ratio = 1.0 * (top - bottom) / (right - left);  

All variables involved are float.
What is the significance of having 1.0 multiplied to the result?
As per my thinking multiplying 1.0 is some extra burden.Since the result wont change.

Or is it similar to write an condition having and 1==1.

P.S: There are some situations where in some variables(except ratio) are assigned to non Float/double values as a long or integer.

  • 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-27T14:23:11+00:00Added an answer on May 27, 2026 at 2:23 pm

    C/C++

    When one or more of the variables top, bottom etc. are of type double then the multiplication by 1.0 is pointless. You should simply remove it since it serves no purpose. When all of the variables are of type float then the multiplication by the double literal 1.0 forces the expression to be evaluated with double precision arithmetic.

    On the other hand, when all of the variables are integers, the multiplication by 1.0 forces the calculation to be performed with floating point arithmetic. Without the multiplication the calculation would be performed with integer arithmetic which would yield a different result.

    My guess is that the code originally used integers and the 1.0 was needed. At some point in time the code was changed to use floating point variables but the now spurious multiplication was not removed.

    Delphi

    If you saw such an expression in Delphi code then you should simply remove the multiplication. The presence of a division operator forces the expression to be evaluated as a floating point expression.

    The rules for Delphi expression evaluation are a little different from C and C++. In C and C++ a single symbol, / is used for both integer and floating point division, with the context of the expression determined which form of division is used. In Delphi / is floating point division and div is integer division.

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

Sidebar

Related Questions

I happen to come across a Java code at my work place. Here's the
I'm just getting started with Ember and come across this issue while writing some
So I'm doing some Prolog in SWI-Prolog and I've come across a little snag.
doing some exercise from a book I've come across a doubt. I've defined some
Just happen to come across a type called NativeArray in JavaScript. Not sure what
I've come across some javascript code in our codebase that stands out as dangerous
I am looking over some code to review and have come across a busy
I happen to come across many statements like comparable is used when natural ordering
I come across several problems while trying django unittests library. Something strange happens: I
do you happen to know if there is a way to define both elements

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.