• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

input is ignoring the decimals and treating decimal numbers as whole numbers

 
Ranch Hand
Posts: 205
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a code-pen here: https://codepen.io/ebonymaw/pen/jOrJWMy

It's pretty simple, but I'm proud of it

But wait a second! There's a bug in here!

In Property Tax Rate, no matter what I put after a decimal point, it is ignored! 1.2916 simply becomes 1.
"2.5353" becomes 2. What am I doing wrong here?

line # 49, of my Javascript:

looks fine to me....

Can someone please point out what might be happening here?

Thank you!
 
Marshal
Posts: 26135
77
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm no JavaScript guru but still, that's what I would expect of a method named "parseInt".
 
Marshal
Posts: 67478
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Easy way to convert to number:
 
Mark Richardson
Ranch Hand
Posts: 205
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:I'm no JavaScript guru but still, that's what I would expect of a method named "parseInt".



Aha! Apparently, there's a parseFloat! Thank you :)

I assumed that parseInt was just a catch-all for all numbers.. since Javascript just has one datatype for Numbers...
 
Forget this weirdo. You guys wanna see something really neat? I just have to take off my shoe .... (hint: it's a tiny ad)
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic