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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:30:37+00:00 2026-06-09T03:30:37+00:00

I have a rather odd bug in an application which I have managed to

  • 0

I have a rather odd bug in an application which I have managed to narrow down to this simple test case.

protected void Page_Load(object sender, EventArgs e)
{
    bool isHeightExceeded = IsHeightExceeded(10.16f, 127.15f);
    lit.Text = isHeightExceeded.ToString();
}

private bool IsHeightExceeded(float y, float height)
{
    float nextHeight = y + height;
    return (137.31f - nextHeight) < 0;
}

When I build and run this in debug mode the isHeightExceeded bool is False (as I would expect) however when I rebuild and run in release mode it is now True.

What is happening behind the scenes to cause this? I am guessing it has something to do with floating point precision but not exactly sure what.

Any help would be appreciated.

  • 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-09T03:30:39+00:00Added an answer on June 9, 2026 at 3:30 am

    I suspect that the value of 10.16f + 127.15f is computed in 64 (or 80) bits and then compared with 137.31f… whereas in release mode the value is computed, then truncated to 32 bits and then compared. Basically when intermediate values aren’t clamped to a smaller precision, you can get results like this.

    If it’s an issue, that probably suggests you shouldn’t be using float or double to start with – if these are meant to be precise values, use decimal instead.

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

Sidebar

Related Questions

I have some rather odd behavior in my D program that I've narrowed down
I have a quite odd mystery. I have a rather simple Apache Rewrite and
Let give you the details of this rather odd issue. We have a very
I am making my first WPF application, so this question may seem rather odd.
Ok, I have some rather odd behavior in one of my Projects and I'm
I have recently been faced with a rather odd task, one result being the
I am having a rather odd problem with the Gecko Webbrowser control, I have
Have a rather simple question. Does anyone knows if i can use jparallax both
I have a rather large text corpus, of which I would like to check
I have a rather simple ListView row: <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=wrap_content

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.