Logical conjuctions on if condition | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

18th Mar 2020, 5:38 AM
p1k4ss4ur0
p1k4ss4ur0 - avatar
3 Answers
+ 1
Hello Mr Cuckson Can you elaborate further on this idea? I'm not getting the Description very clearly : )
18th Mar 2020, 6:13 AM
Ipang
+ 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)
18th Mar 2020, 6:34 AM
p1k4ss4ur0
p1k4ss4ur0 - avatar
+ 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 : )
18th Mar 2020, 6:47 AM
Ipang