MadnessRed Posted August 17, 2009 Share Posted August 17, 2009 I have this code... if(a > b){ //Do some stuff }else{ alert(a + ' < ' + b); } And when I run it, I get this in the alert. 13941 < 892.07415525 Could someone please tell me why that this is the case, as 13941 is clearly greater than 892 Quote Link to comment https://forums.phpfreaks.com/topic/170747-help-with-simple-if-which-is-acting-oddly/ Share on other sites More sharing options...
MadnessRed Posted August 17, 2009 Author Share Posted August 17, 2009 I think I worked it out. it was reading it as a string and that mean it was textually less than not numerically less that. Like if you sort alphanumerically 1-9,a-z, then 123 < 7 in the same wasy that abc < g. So to fix I multiplied both by 1 which made them into numbers Quote Link to comment https://forums.phpfreaks.com/topic/170747-help-with-simple-if-which-is-acting-oddly/#findComment-900528 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.