alphacyberranger@lemmy.world to Programmer Humor@programming.devEnglish · 2 years agoJavalemmy.worldimagemessage-square59fedilinkarrow-up1498arrow-down141
arrow-up1457arrow-down1imageJavalemmy.worldalphacyberranger@lemmy.world to Programmer Humor@programming.devEnglish · 2 years agomessage-square59fedilink
minus-squaremaniacal_gaff@lemmy.worldlinkfedilinkarrow-up27arrow-down1·2 years agoIt would be kinda dumb to force everyone to keep casting back to a double, no? If the output were positive, should it have returned an unsigned integer as well?
minus-squarelarvyde@sh.itjust.workslinkfedilinkarrow-up14·2 years agoint coerces to double automatically, without explicit casting
minus-squaresnake_baitman@lemmy.sdf.orglinkfedilinkarrow-up15·2 years agoThe CPU has to do real work to convert between float and int types. Returning an int type would just be giving the CPU extra work to do for no reason
minus-squareNotNotMike@programming.devlinkfedilinkarrow-up3·2 years agoI’m learning so much from this thread and I don’t even use Java
It would be kinda dumb to force everyone to keep casting back to a double, no? If the output were positive, should it have returned an unsigned integer as well?
int
coerces todouble
automatically, without explicit castingThe CPU has to do real work to convert between float and int types. Returning an int type would just be giving the CPU extra work to do for no reason
I’m learning so much from this thread and I don’t even use Java