[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

>work on a personal project in Java >notice arithmetics

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 27
Thread images: 3

>work on a personal project in Java
>notice arithmetics start to spew out shit at one point
>started debugging
>245 / 255 * 235 evaluates to 0 in Java
What the actual fuck?
>>
>>55327945
>2016
>sublime text
PLEB
L
E
B
>>
are you sure it's java and not just shitty intellisense?
>>
Poo in loo Rajeet.
>>
>>55327945
>why do I have to care about data types?!
Have you considered using Python or PHP? It tries to cater to your kind.
>>
>>55327945
>doesn't understand integer arithmetic
>blames it on java

WELCOME SUMMER

YOU MUST BE 18+ TO USE 4CHAN

GET THE FUCK OUT
>>
>>55327945
Moron
>>
>>55327945
install gentoo
>>
integer division friendo

245/255 floors to 0 and you can do the rest
>>
>>55328039
At least this is better than RX480 thread #90000
>>
>>55328078
I have those threads filtered though. You can't filter OP's kind of stupidity
>>
File: par72bb1[1].jpg (21KB, 240x260px) Image search: [Google]
par72bb1[1].jpg
21KB, 240x260px
>>55328078
it's about on par
>>
>>55327945
245/255 will be casted to 0 since it's an integer division.
>>
File: 1465007610498.png (533KB, 500x525px) Image search: [Google]
1465007610498.png
533KB, 500x525px
>>55328100
>casted
>>
>>55327945
so since you're an absolute fuckwit and have no experience in programming whatsoever, it'd be a dick move to not teach you something:
if you want to use a number as a float, you can use "245f" instead of 245 (similarly 245l will be long)
if you use 245.0, it is double
>>
>>55327945
Add .0 at the end of the numbers to make them floating-point.
>>
>>55327945
That is shit code and you don't understand what you're doing. I recommend you read a book, friendo
>>
>>55328155
>245f
is that typecasting?
>>
>>55328155
>>55328068
>>55328100
Thanks, got it now.
>>
>>55328217
No, that declares a float literal. A cast would be

(float)245
>>
>>55328217
not really. casting means taking one thing and making it something else. 245f just initializes that number to be float. There is never an integer representation of 245 made. But in a more semantic sense, you might call it casting
>>
>>55328068
>>55328100
>>55328155
Am I the only one that would fix this by changing it to 245 * 235 / 255 to keep the math integer based?
I guess AVR has changed me.
>>
>>55328323
Yes, because that still doesn't get the answer OP wants.
>>
>>55328323
this implies that OP actually wanted an integer back.
>>
>>55328346
>>55328367
OP didn't specify. I assumed he just wanted a non-zero answer
>>
>>55328410
If he's surprised by getting zero from that expression he clearly wanted a floating point answer.
>>
>>55328086
this
Thread posts: 27
Thread images: 3


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.