nixCraft, (edited )
@nixCraft@mastodon.social avatar

Poll: What value is typically used to represent the concept of "true" (Boolean) in most programming languages?

hstone32,

@nixCraft what do you mean >0 OR <0? I haven't used any languages that interpret negative numbers as true. I guess there might be some that cast negative numbers to unsigned integers, but i dont think even C does that.

brooksie155,

@nixCraft in some languages it’s not what is true, but what is false. in PHP, when not being strict, 0 or and empty string is false, as is the boolean false obvs. pretty much everything else is not false.

lemgandi,
@lemgandi@mastodon.social avatar

@nixCraft Well, in a truly righteous world, 0 would be True//Success//OK and any other value would be False. There are many errors, but only one truth. Alas, we live in a Fallen world.

DominicDeligann,

@nixCraft i thought it was "false = 0" and "true = 1". maybe its a C thing.

rotopenguin,
@rotopenguin@mastodon.social avatar

@nixCraft True anInstance.

lanodan,
@lanodan@queer.hacktivis.me avatar

@nixCraft I'd say both because Unix (C has non-0 as truthy, yet most C functions return 0 for success, meanwhile shell has success as 0).

joaquimCarneiro,
@joaquimCarneiro@fosstodon.org avatar

@lanodan @nixCraft exactly what i was going to say 😜

kaia, (edited )
@kaia@brotka.st avatar

@nixCraft true cannot be a number, because JavaScript says so :aismug:

nixCraft,
@nixCraft@mastodon.social avatar

@kaia haha. i knew it someone will bring it

patricus,

@kaia @nixCraft what's this image?

kaia,
@kaia@brotka.st avatar

@patricus @nixCraft
added alt text: "Javascript interpreter in the browser that shows parseInt(true) and its result NaN"

lanodan,
@lanodan@queer.hacktivis.me avatar

@kaia @nixCraft 0 in JS is falsy though:

Welcome to Node.js v20.12.1.
Type ".help" for more information.
> !!0
false

hj,
@hj@shigusegubu.club avatar

@kaia @nixCraft you're feeding a boolean into a function that expects a string, so it converts true to "true" and string "true" fails integer parsing :nerdmouse:

kaia,
@kaia@brotka.st avatar

@hj @nixCraft
I didn't claim I knew what I was doing :hehe:

hj,
@hj@shigusegubu.club avatar

@kaia @nixCraft i'm just explaining the logic behind it

nik,

@hj @kaia @nixCraft oh yeah? explain this

hj,
@hj@shigusegubu.club avatar
  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • Durango
  • DreamBathrooms
  • InstantRegret
  • tacticalgear
  • magazineikmin
  • Youngstown
  • thenastyranch
  • mdbf
  • slotface
  • rosin
  • Leos
  • kavyap
  • modclub
  • ethstaker
  • JUstTest
  • everett
  • GTA5RPClips
  • cubers
  • khanakhh
  • ngwrru68w68
  • anitta
  • provamag3
  • cisconetworking
  • tester
  • osvaldo12
  • megavids
  • normalnudes
  • lostlight
  • All magazines