There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

programmer_humor

This magazine is from a federated server and may be incomplete. Browse more on the original instance.

Acetamide , in Java
@Acetamide@lemmy.world avatar

AFAIK most typed languages have this behaviour.

Lmaydev ,

Because ints are way smaller. Over a certain value it would always fail.

larvyde ,

Yea but at those values floating points can’t represent fractions anyway

Lmaydev ,

Exactly. So if cast to int you’d either get an error or 0 for everything above a certain value.

MrGeekman , in Java

Try Math.round. It’s been like ten years since I used Java, but I’m pretty sure it’s in there.

bappity , in Java
@bappity@lemmy.world avatar

the programming language Java meaning coffee is perfect because, like coffee, it tastes like shit but gets the job done

MrGeekman ,

I think you need to try some lighter-roasted, higher-quality beans which were roasted fairly recently and only grind them a day or so before you use them. There are also different brewing methods and coffee/water ratios that you can try.

mestari ,

I love and consume lots of coffee but I sincerely believe it only tastes good because I associate the taste with the boost it gives. Exactly like cigarettes taste tolerable, good even, when you smoke them regularly.

MrGeekman ,

If you don’t know what you’re drinking, it’s probably dark roast. Dark roast is like charcoal compared to light roast.

The coffee most folks use (i.e. Folgers, Maxwell House) is low-quality coffee made in haste to keep the price low enough for folks to be willing to buy it. They only offer darker roasts because disguise the inferior nature of the beans, or rather the inferior process. The unfortunate truth is that good coffee costs more to process because it takes longer to process and most folks don’t want to spend that much on coffee. So, you get what you pay for.

cia ,

It is shit, Austin

maniacal_gaff , in 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?

larvyde ,

int coerces to double automatically, without explicit casting

snake_baitman ,

The 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

notnotmike ,
@notnotmike@programming.dev avatar

I’m learning so much from this thread and I don’t even use Java

baseless_discourse ,

I think one of the main reason to use floor/ceilling is to predictably cast a double into int. This type signature kind of defeats this important purpose.

I don’t know this historical context of java, but possibly at that time, people see type more of a burden than a way to garentee correctness? (which is kind of still the case for many programmers, unfortunately.

BorgDrone ,

You wouldn’t need floor/ceil for that. Casting a double to an int is already predictable as the java language spec explicitly says how to do it, so any JVM will do this the exact same way.

The floor/ceil functions are simply primitive math operations and they are meant to be used when doing floating point math.

All math functions return the same type as their input parameters, which makes sense. The only exception are those that are explicitly meant for converting between types.

baseless_discourse , (edited )

“predictable” in the sense that people know how it works regardless what language they know.

I guess I mean “no surprise for the reader”, which is more “readability” than “predictability”

BorgDrone ,

Is there any language that doesn’t just truncate when casting from a float to an int?

baseless_discourse ,

As far as I know, haskell do not allow coresion of float to int without specifying a method (floor, ceil, round, etc): https://hoogle.haskell.org/?hoogle=Float±%3E+Integer&scope=set%3Astackage

Agda seems to do the same: agda.github.io/agda-stdlib/Data.Float.Base.html

uphillbothways , in Always write comments
@uphillbothways@kbin.social avatar

test comment. please ignore.

weird_nugget , in Movies vs life

So you’re saying you program without a translucent mini map showing your location or whatever? Shame on you.

ExperimentalGuy , (edited ) in waiting for rust-analyzer

I kinda love how fast the binaries are. I was timing something I wrote and, as a mostly Python dev, I was so confused when the program was running in the microseconds or something crazy like that and not milliseconds.

Beanie ,

uh I think you mean microseconds lol

A nanosecond is just a few clock cycles

ExperimentalGuy ,

Thanks, that’s what I meant I just forgot what it was

Sigmatics , in waiting for rust-analyzer

I thought Rust was fast

Zalack ,
@Zalack@startrek.website avatar

Compiled Rust is fast.

Compiling Rust is slow.

Also my understanding is that RustAnalyzer has to compile all Rust macros so it can check them properly. That’s not something that a lot of static analysis tools do for things like C++ templates

5C5C5C ,

Personally I think the “compiling Rust is slow” narrative comes from comparing it against scripting languages like Python. If you compare compiling Rust against compiling C++ code of similar complexity, I think Rust will come out very favorably since C++ templates and headers tend to carry a huge compilation burden.

Neato , in Null terminator
@Neato@kbin.social avatar

Is this anything that a simple admin password reset wouldn't fix? It's not like admins can see your passwords anyways. (if the system is even remotely competent)

perviouslyiner ,

if the system is even remotely competent

perviouslyiner , in Null terminator

At least he’s not holding it by the top of the screen like Black Hat Guy.

behindthesailboats , in Null terminator

Right, So I actually did something similar. On some version of windows I noticed that ctrl-backspace was adding another character to the password, instead of deleting it. So I included it in my password. Then I updated to a new version of windows and got locked out since they updated the password backend to where it would actually delete the password instead of a adding the character, so I had no way of typing out my password. Ended up just nuking the computer.

x4740N ,
@x4740N@lemmy.world avatar

Could have just researched what character was being inserted by the ctrl backspace and then used the keyboard to insert the character from its ascii or unicode code to login and then changed your password before nuking your computer

mercator_rejection ,

But with what computer?!

ludwig ,

Your phone maybe?

Jumper775 ,

Your what? Like those things with the dial that are attached to the wall? How are you meant to do it with that?

bstix ,

Easy. You whistle in binary and say modem noises. The operator will patch you through to the internet.

DrQuint ,

Oh, you’re young

StudioLE , in Movies vs life

I’ve been playing around with Grafana alot lately so my screens do look closer to the second. Except not such a disordered jumble so it doesn’t have any where near the same wow factor

teft , in Null terminator
@teft@startrek.website avatar

Title text: My password is just every Unicode codepoint concatenated into a single UTF-8 string.

Norgur , in Null terminator

Doing that to annoy devs who didn't sanitize their database inputs is like walking along parking lot just to see if anyone has forgotten to lock their car, just to put a post it in the steering wheel.

daw_germany ,

Nah man, not sanitizing Inputs could pose serious security risks as someone could use this shit to escape and run arbitrary database queries potentially leaking passwords or other info or just wiping it (Afa I have learnt on the internet)

YonatanAvhar ,

Just like @Norgur said, leaving your car unlocked is a serious security issue and you’d be lucky if someone walked by and just left a post-it note

Noodlez , in Null terminator

Now I want to try this.

db2 ,

Now I want to try this."; DROP TABLE ‘users’;

ftfy

ButWhatDoesItAllMean ,

Little Bobby Tables

Revan343 ,

I really want to start a synth band called Robert and the’); DROP TABLE ‘artists’;

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines