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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:54:17+00:00 2026-06-02T17:54:17+00:00

Context : We have business requirement that a value is reported at 3 or

  • 0

Context : We have business requirement that a value is reported at 3 or 4 digit string. If the string is 3 digits, it’s value is actually *10.

e.g. 123 represents 1230, where as 4567 represents 4567.

When converting back from a stored integer to the string, the above code is seen as one way to determine this. The question we have is would the optimizer remove this code for x (integer and float). Specifically looking at Java, but the follow on question is how would other languages behave

The obvious other way to do this is use Mod (x%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-06-02T17:54:19+00:00Added an answer on June 2, 2026 at 5:54 pm

    Your question makes a false presumption that (x/10)*10 necessarily equals x. In general, Java compilers and virtual machines are allowed to optimize anything any way they want to so long as they satisfy the requirements of the Java Language Specification.

    If x is a float or a double then x == (x/10)*10 if there is no floating point rounding error. However, 10 is an int and if x is an int or long then the expression uses Integer division. The Java Language Specification is crystal clear on what the division operator does with respect to integers. Namely it rounds toward zero. So the Java compiler may optimize that expression to something other than a divide followed by a multiply, but whatever the optimizer does, it has to produce the correct result.

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

Sidebar

Related Questions

I have a SharePoint list with Content Approval enabled. The business requirement is that
Context: I have a class that implements a Session, maintaining a TCP connection to
I have a LINQ TO SQL Context that I have created that calls a
I have a core data context with objects that have a date stored in
I have in my applicationContext.xml <context:property-placeholder location=classpath*:*.properties /> <bean id=clientPreferencesManager class=pl.bildpresse.bildchat2.business.ClientPreferencesManager > <property name=clientApiUrl
I have a pre-existing c++ object model which represents the business layer tier of
Assume the following problem context: 1) In our application, we have a business object
Okay, I have a business logic class like this: Note: For context, Vendor Briefs
The context is that I have one cached set of values in memory that
I have a business class. In this business class there are : a context

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.