Do you see where I'm going here? Because in both cases: WRONG.
Let's start with the fact that libraries pay for each copy of the book they provide (print or digital), and then they pay to replace copies that are worn out by repeated borrows, or for extra copies if there is demand. And yes, authors receive royalties for each of those.
"But I still have to go to the library to get the book!"
I've heard this more times than I've bothered to count, and the thing is: it's not true. Libraries now provide both digital and audio books—and you can borrow them right from your home! Just log in to your library account, find the book, and click. (And with library copies, you don't have to be worried about any nasty viruses or other surprises.) Sure, occasionally there aren't as many copies as interested readers. And sometimes your library doesn't have the book you're looking for. If so, many will give you the opportunity to request they purchase a copy, giving you the book you want while also compensating the author.
It's true that in both those cases you may have to wait a little while. But if you absolutely must read that book right this second, maybe you should be buying it.
Because the alternative is stealing from authors. And make no mistake, reading pirated books is stealing from the person who spent months or years creating that story. So rather than theft, take advantage of the legal, convenient, and mutually beneficial service libraries provide!
And to celebrate the awesomeness of libraries, share the last library book you borrowed in the comments! For me, it was Uprooted by Naomi Novik.