+ 3

Return bool or 1/0

What would be the correct (or more efficient) way to return a value of a function?

27th Mar 2018, 4:08 PM
Marfik Em
Marfik Em - avatar
2 Respostas
+ 5
If you just need true or false then use bool. Bool takes 1 byte, while int uses 4. Doesn't make that much difference in efficiency on most systems, but it also makes your code more readable in my opinion.
27th Mar 2018, 4:49 PM
Alex
Alex - avatar
+ 14
most programming languages use boolean, but for example in C you don't have boolean so you can use 1 for true and 0 for false
27th Mar 2018, 8:17 PM
Vukan
Vukan - avatar