Author Topic: Question about bool and boolean  (Read 134 times)

0 Members and 1 Guest are viewing this topic.

Arnold

  • Hero Member
  • *****
  • Posts: 741
Question about bool and boolean
« on: November 27, 2018, 01:14:17 AM »
Hi Charles,

in the past you changed the value of true to -1 sometime. This makes sense to me:

Code: OxygenBasic
  1. uses console
  2.  
  3. printl "true = "true
  4. printl "not true = " not true
  5. printl "not false "  not false
  6. printl
  7. printl "not 1 = " not 1
  8.  
  9. printl "Enter ..." : waitkey
  10.  

Some languages define true as a value of 1. Will it be safe if I use: % true=1 in the beginning of my code?

I noticed that there are the types bool and boolean. I assume there is no difference between these two types?

Roland

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3946
    • Oxygen Basic
Re: Question about bool and boolean
« Reply #1 on: November 27, 2018, 04:57:14 AM »
Hi Roland,

Glad you raised this subject. In the new o2, true will have a value of 1 by default. Comparators (A>B) will also return 1 when true.

I'm using the MS interpretation of Bool and Boolean:
Bool is 32bit (generally preferred)
Boolean is 8bit

Currently, they are pseudo-types. To be truly boolean they should be masked to 1bit.

« Last Edit: November 27, 2018, 05:11:14 AM by Charles Pegge »