PDA

View Full Version : Parsing a number, float versus integer


Noct
10-06-2008, 03:10 AM
In a best practice/"cleanest code possible" type scenario, would you stop to evaluate whether a number contained a decimal before you did a parseFloat on it?

I'm parsing user entered equations, and since they can enter a decimal, I currently have it just parseFloat-ing eveything to be safe.

Since my App does not perform these equations rapidly, I can't imagine it would really matter performance-wise, but I'm wondering if practices would suggest that I only use pInt on ints and pFloat on dec...

Any thoughts?

pj-co
11-15-2008, 12:42 AM
If the users have entered a number, go with number. why over think it? :)