Why is ("1e3" == "1000") true? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

Why is ("1e3" == "1000") true?

<?php if("1e3" == "1000") echo "wow"; else echo "nop"; ?> Is true and print "wow"; Could someone explain it to me?

22nd Jan 2018, 6:07 PM
mmo
5 Answers
+ 10
I think this is scientific notation used for numbers 1000 = 10^3 = 1 * 10^3 = 1 e3 and after some trial and error i think this is true try this -> 100 == 1e2 300 == 3e2 5000 == 5e3
22nd Jan 2018, 6:30 PM
code learner
code learner - avatar
+ 6
Yeah it works in php I don't know why. in the string the first letter represents the number first letter.The "E" does the real thing.the third letter represents number of 0's 1e3==1000 1e1==10 1e4==10000 4e3==4000
22nd Jan 2018, 6:38 PM
᠌᠌Brains[Abidemi]
᠌᠌Brains[Abidemi] - avatar
+ 2
echo 1e8; works too btw. :-) Thanks!
22nd Jan 2018, 6:43 PM
mmo
+ 1
why did u use dollar symbol
23rd Jan 2018, 8:12 AM
arun