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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:30:24+00:00 2026-06-11T03:30:24+00:00

First I test that every variable got a number value: 09-11 18:15:00.420: d_drop: -1.178791867393647

  • 0

First I test that every variable got a number value:

09-11 18:15:00.420:
       d_drop: -1.178791867393647
  drop_at_zero: 0.0731037475605623
   sightHeight: 4.5
    d_distance: 40
     zeroRange: 10

09-11 18:15:00.420:
       d_drop: true
  drop_at_zero: true
   sightHeight: true
    d_distance: true
     zeroRange: true

function isNumber (o) {
  return ! isNaN (o-0) && o != null;
}

 var d_drop; // in calculation this gets value 1.1789

 var d_path = -d_drop - sightHeight + (drop_at_zero + sightHeight) * d_distance / zeroRange;

console.log("Path: " + d_path + " cm");

and in the log:

09-11 18:15:00.430: D/CordovaLog(1533): Path: NaN cm

WHY? I have tried to figure that out couple of hours now and no success, maybe someone has an idea, I haven’t!

Thanks!
Sami

——-ANSWER IS that parse every variable when using + operand———–

var d_path = parseFloat(-d_drop) – parseFloat(sightHeight) + (parseFloat(drop_at_zero) + parseFloat(sightHeight)) * parseFloat(d_distance) / parseFloat(zeroRange);

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

    The addition operator + will cast things as strings if either operand is a string. You need to parse ALL of your inputs (d_drop, sightHeight, etc) as numbers before working with them.

    Here’s a demo of how the + overload works. Notice how the subtraction operator - is not overloaded and will always cast the operands to numbers:

    var numberA = 1;
    var numberB = 2;
    var stringA = '3';
    var stringB = '4';
    
    numberA + numberB // 3 (number)
    numberA - numberB // -1 (number)
    stringA + stringB // "34" (string)
    stringA - stringB // -1 (number)
    numberA + stringB // "14" (string)
    numberA - stringB // -3 (number)
    

    http://jsfiddle.net/jbabey/abwhd/

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

Sidebar

Related Questions

Let’s say that my string is: test! I want to get the first character
Is there any way to first test if a file is in use before
Can someone explain to me why the following works for the first test but
I just started looking at android app development. For my first test app i
I created an ASP.NET MVC 2.0 Application. It ran fine at first test and
I am trying to add my first unit test to an existing Open Source
I'm playing with Mockito (1.9.5) and stuck at first simple test case: List mockedList
I have strange behaviour in Python/PyMongo. dbh = self.__connection__['test'] first = dbh['test_1'] second =
I'm trying to test the first answer to this question: SQL - message schema
I've been the past days trying to test my first in-app purchse iphone application.

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.