0

I have a function to return points along a line and my return comes back with two decimal points...? For example, a return of my variable px will be something like -88.4029.032940598.

vx is the x vector and mult is the distance of the line plus distance to calculate the point. Here is the operation that is returning these values:

var mult = parseFloat(mag + theUnit);
var px = coord_one.x_point + (vx * mult);
console.log(px);

Never have seen this before- I appreciate any and all help!

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
muzzledBYbrass
  • 276
  • 1
  • 3
  • 11
  • 4
    Seems like one of your values is a string (it can only be `coord_one.x_point`) and you are performing string concatenation of two floating point values instead of addition. Convert the operand to a number first: `+coord_one.x_point` (why do you store the value as string in the first place?). – Felix Kling Jul 02 '13 at 22:58
  • Actually, what Felix Kling said. – bfavaretto Jul 02 '13 at 22:59
  • thanks guys- i've been looking at these articles and I think you're probably right. ugh sucks when you're blind to the obvious after staring at code for hours. – muzzledBYbrass Jul 02 '13 at 23:02

1 Answers1

0

you need to parseFloat the coordonexpoint as well as the vx*mult first

Ron
  • 514
  • 2
  • 13