User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » javascript help Page [1]  
Novicane
All American
15416 Posts
user info
edit post

I have text boxes that take in numbers. My problem is when i add decimals, my remainder doesn't return a "0" in front on my number on single digit remainders.

code:

main code, return the decimal of the number. (i.e 01,02,13,14, etc) The decimal is manually handled else where in the code.


Math.round(getRemainder(hour / 100))


my getRemainder function

function getRemainder(val)
{
return parseFloat((val - parseInt(val))*100);

}


My example: 0.55 + 0.50 = 1.5, it should really equal 1.05.

1/8/2010 4:08:22 PM

Golovko
All American
27023 Posts
user info
edit post

why are you returning a float if you're rounding?

1/8/2010 4:30:56 PM

Novicane
All American
15416 Posts
user info
edit post

left it in there, was ParseInt. (i did not write this code)

Pretty much in my getRemainder function, if i multiply by 100, i'm losing my zero.

I'm just going to convert it a string, strip the decimal, and return it as a string. Take out all the round BS because its not going to work.

1/8/2010 4:39:42 PM

Golovko
All American
27023 Posts
user info
edit post

Whats the big picture that you are trying to do rather than just posting your/someone else's solution. That might yield better responses/help.

1/8/2010 4:41:54 PM

Novicane
All American
15416 Posts
user info
edit post

i've got it now. Thanks,

1/8/2010 4:50:27 PM

qntmfred
retired
40726 Posts
user info
edit post

np

1/8/2010 5:13:10 PM

Golovko
All American
27023 Posts
user info
edit post

Quote :
"np"

1/8/2010 5:23:55 PM

 Message Boards » Tech Talk » javascript help Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.39 - our disclaimer.