[Algorithm]-[Question 065] why "2e10" is valid but "abc" is not ...?


  • 0
    D
    "2e10" => true 
    

    --- ok, so we also take HEX numbers according to this example.

    "abc" => false 
    

    ---- so why this is false? it could also be a HEX number.

    And why this is false...?

    Input: 	"0e"
    Output: 	true
    Expected: 	false
    

    And why this is false...? Isn't it also a HEX number?

    Input: 	"e9"
    Output: 	true
    Expected: 	false
    

    I cannot believe my eyes......, What's the difference between this "5e" and that TRUE "2e10"...??

    Input: 	"5e"
    Output: 	true
    Expected: 	false

  • 4
    B

    I think 2e10 represents 2 exponential 10 i.e. e stands for exponential. Valid format for exponentials is: aeb
    where a and b are decimal numbers. Whereas 5e or e9 are not valid numbers in exponential form.
    Link: http://en.wikipedia.org/wiki/Scientific_notation
    Read Section E-notation
    Hope this clarifies your doubt.


  • 0
    D

    Yes I think you're right~! Thanks a lot!


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.