BananaTrifleViolin, (edited )

The actual answer in on Stack exchange in their comments.

unix.stackexchange.com/…/why-is-gnome-fractional-…

It is related to a mix of actual display resolution vs conversions to virtual resolutions (the scaled resolution), and use of single precision floating point calculations.

Essentially my understanding is what it is doing is storing the value needed to convert your actual resolutions number of pixels (2160p) to a virtual resolution number of pixels (2160/1.75 horizontally) but that gets you fractions of a virtual pixel. So instead of 1.75 it scaled by 1.75182… to get to a whole number of virtual pixels to work with. Then on top of that the figure is slightly altered from what we’d expect by floating point errors.

If you take the actual horizontal resolution 2190 and divide it by the virtual resolution it’s trying to use 1233 pixels, you need a conversion value of 1.75182… to convert to it so you don’t get fractions of a pixel. If you used 1.75 you’d get 1234.2857… pixels. So gnome is storing the fraction that gets you a clean conversion in pixels to about 4 decimal places of a pixel.

Full credit to rakslice at Stack Exchange who also goes into the detail.

Dirk,
@Dirk@lemmy.ml avatar

For the same reason a lot of programming languages can’t calculate 0.1+0.2 properly.

https://lemmy.ml/pictrs/image/800d9121-8b45-421a-b3a1-3a866750899f.png

There’s a website explaining it: 0.30000000000000004.com

MotoAsh,

Floating point error? Yeaahhh no. No. Just… no. That is NEVER as big as 0.01 unless the number is also insanely massive.

The error is relative in scale. It’s not magically significant fractions off.

Giooschi,

TBF the error can become that big if you do a bunch of unstable operations (i.e. operations that continue to increase the relative error), though that’s probably not what is happening here.

ElectroLisa,
@ElectroLisa@lemmy.blahaj.zone avatar

If I’m not mistaken 1.75 can be correctly stored as a float, as it consists of 1/2 and 1/4 only

Aradia, (edited )
@Aradia@lemmy.ml avatar

Gnome is coded with JavaScript (lmao 🤣) so yeah, I Think you are right.

EDIT: Actually, even if JavaScript and other languages have this issue, the value 1.7518248558044434 has not this issue. There is another reply that explains it and makes totally sense. But still pretty lame to know the desktop runs with JavaScript. (Yeah, I hate Gnome)

atzanteol,

It’s not a “language” issue it’s a “computer” issue. This math is being done on the CPU.

IEEE 754

Some languages do provide for “arbitrary precision math” (Java’s BigDecimal for example) but it’s slower to do that. Not what you want if you’re multiplying a 4k matrix every millisecond.

Aradia,
@Aradia@lemmy.ml avatar

I see, thanks for the explanation.

priapus,

GNOME is primarily written in C

Aradia,
@Aradia@lemmy.ml avatar

Okay, but still needs JavaScript, they are slowly trying to remove or improve it. But it is a fact that it also runs on JavaScript. 🤣

priapus,

Using JavaScript isn’t inherently a bad thing. JavaScript can be very useful when used for scripting. Obviously anything with a new for performance will be done in C.

Aradia,
@Aradia@lemmy.ml avatar

JavaScript isn’t the best language to make a desktop interface in my opinion, it can be very efficient, but you can see in bugs (at least in the past) how bad performance it had, and they needed to re-factor it to replace to C or improve the JavaScript. I’m just laughing and making fun of it using JavaScript, not saying it is slow, Gnome is pretty fast nowadays.

yukijoou,

the desktop shell is mostly javascript though

Aradia,
@Aradia@lemmy.ml avatar

Yeah, on their git says 46% of the code is JavaScript: gitlab.gnome.org/GNOME/gnome-shell

That’s pretty much, almost half of the code.

priapus,

That page also shows that there is more C. That page is also specifically the shell, not all of the desktop.

Aradia,
@Aradia@lemmy.ml avatar

There is less than 4% more code in C than JavaScript. That’s pretty much, many features on the gnome-desktop is using JavaScript too, like gestures and mouse events.

priapus,

Closer to 50/50, and other parts of the GNOME desktop like mutter, are largely C. Saying the entire GNOME desktop is mostly JS is silly.

kbal,
@kbal@fedia.io avatar

On the other hand, saying that there's way too much javascript in it is objectively factual.

priapus,

You don’t get to decide what too much JS in the project is unless you actually work on and have in depth knowledge of the project. I dont like JS, but it has its uses.

Many people are conflating modern electron bloatware with ‘JS bad’, but things are not that simple.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • linux@lemmy.ml
  • localhost
  • All magazines
  • Loading…
    Loading the web debug toolbar…
    Attempt #