Logical conjuctions on if condition | SoloLearn: Learn to code for FREE!

0

Logical conjuctions on if condition

How can i compare the logical conjuction of a number in a if condition? Exemple: 1 being diferent of -1 cuz 1 is natural and -1 integer

3/18/2020 5:38:04 AM

Mr Cuckson

3 Answers

New Answer

+1

Hello Mr Cuckson Can you elaborate further on this idea? I'm not getting the Description very clearly : )

+1

Its a programm where you imput any number and the algorithim returns the mumber conjuct of this number in strings, if you input √2, will be returned "irrational", if you input 1.1 will be returned "float", if you input -1 will be returned "integer" (im brazilian sorry if i get something wrong things are named different here)

+1

This is quite tricky. Anyways, English is okay. I am not native English speaker either, but now I understand what you mean better. Which language are you doing this? I suggest add language name in your thread tags, just to improve context clarity. Personally, I would first check whether first character is minus sign '-'. This means negative number. From the second character check every character be either digit, or a '.' (Decimal point). If any character was neither one of these, input may be wrong. If decimal point '.' is found, it is possibly a float. But this approach is not so good, because decimal point in different culture may differ. Some uses ',' instead of '.'. Hope you get what I mean : )