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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:24:58+00:00 2026-06-03T00:24:58+00:00

How can I find the smallest positive (non-zero) number in an array of doubles?

  • 0

How can I find the smallest positive (non-zero) number in an array of doubles? For example, if the array contains 0.04, 0.0001, and 0.0, I want to return 0.0001.

The below function is good, but it will return zero as the min, which is not my interest.

static double[] absOfSub = new double[100];
...

private static double compare(double[] ds) {
  double min = absOfSub[0];

  for (double d : ds) {
    min = Math.min(min, d);
  }
  return min;
}

How can I make it ignore zeroes?

  • 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-03T00:24:59+00:00Added an answer on June 3, 2026 at 12:24 am

    You can check for zero:

    double min = Double.MAX_VALUE;
    for (double d : ds) 
    {
        min = (d == 0) ? min : Math.min(min, d);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to find smallest and second smallest number in a list. Can I
I have two lists. I want to find the smallest common number in the
I can find no non-deprecated way of hiding an item in a menu bar
I can find the definition files at http://www.php.net/~helly/php/ext/spl/... but I want to extend DirectoryIterator
Given two arrays A[n] and B[m] , how can I find the smallest window
Question: 2520 is the smallest number that can be divided by each of the
I am searching for the smallest WYSIWG editor i can find. I have tried
If I have a integer number n , how can I find the next
How do you find the smallest unused number in a SQL Server column? I
I can find the JS and HTML code in response by alert() . But

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.