havenwood changed the topic of #ruby to: Rules: https://ruby-community.com | Ruby 2.7.2, 2.6.6, 3.0.0-preview1: https://www.ruby-lang.org | Paste 4+ lines of text to https://dpaste.org | Books: https://goo.gl/wpGhoQ | Logs: https://irclog.whitequark.org/ruby | BLM <3 | Can't talk? Register/identify with NickServ
silverdust has quit [Ping timeout: 272 seconds]
openstruct has joined #ruby
<openstruct> Can someone help me understand why ruby returns the rounded up representation of a float when doing 0.3 + 0.3 but now when doing 0.1 + 0.2?
<openstruct> Oh, it has to do with what's being used. 0.2 + 0.4 gives me the result I was expecting.
silverdust has joined #ruby
wimpog has quit [Quit: wimpog]
<jhass> floats are a mess. Float printing algorithms (yes, there's actually several approaches to this) is an even bigger mess. Don't rely on their .inspect/.to_s output in any way
alexherbo2 has quit [Ping timeout: 272 seconds]
<openstruct> Heh, so I've learned. I never went down the rabbit hole and have been trying to wrap my head around it. I saw the defacto Oracle aricle but it was way over my head.
<jhass> &>> "%.30f %.30f" % [0.3, 0.1 + 0.2]
<rubydoc> # => "0.299999999999999988897769753748 0.300000000000000044408920985006" (https://carc.in/#/r/9wl8)
<jhass> 0.3 is actually not representable, Ruby lies to you
<openstruct> &>> "%.30f %.30f %.30f" % [0.6, 0.1 + 0.5, 0.3 + 0.3 ]
<jhass> no space in front :)
<openstruct> Thanks :)
<openstruct> &>> "%.30f %.30f %.30f" % [0.6, 0.1 + 0.5, 0.3 + 0.3 ]
<rubydoc> # => "0.599999999999999977795539507497 0.599999999999999977795539507497 0.599999999999999977795539507497" (https://carc.in/#/r/9wl9)
silverdust has quit [Ping timeout: 268 seconds]
<openstruct> "%.30f %.30f %.30f" % [0.6, 0.2 + 0.4, 0.3 + 0.3 ]
<openstruct> Whoops
<openstruct> &>> "%.30f %.30f %.30f" % [0.6, 0.2 + 0.4, 0.3 + 0.3 ]
<rubydoc> # => "0.599999999999999977795539507497 0.600000000000000088817841970013 0.599999999999999977795539507497" (https://carc.in/#/r/9wla)
<openstruct> Yeah, floats are drunk.
<jhass> well, there's an infinite number of them but we only have finite storage space
<jhass> so you gotta make some tradeoffs to picking which discrete values you want to be representable
<openstruct> Is there a mathy way to tell if a decimal point can accurately be represented in decimal? I could just write a loop, but now I'm curious for real reason than to scratch an itch.
alexherbo2 has joined #ruby
<openstruct> *represented in base 3 float
<jhass> IEE754 arguably doesn't make the best tradeoffs for most application (fairly low density in low number ranges), there's so alternatives that do better there. But nothing implements them today
<openstruct> My goodness. *** base 2
<jhass> eh, so -> some
<jhass> there's a good resource or two on this but I always forget to bookmark them, sorry
<openstruct> I've always used BigDecimal. I'd be curious to see if there's a good use case for floats.
<openstruct> I've got 100 tabs open so I've likely hit it. My favorite so far is https://floating-point-gui.de/
<jhass> BigDecimal and Rational are good alternatives in Ruby if you need higher precision. For things like money where you can just multiply by the amount of precision you need (most of the time just up to cents), do that and work (and store) with integers
<openstruct> For sure, I end up converting to BigDecimal when applying discounts or what not to a price.
<openstruct> Thanks for chatting it out with me :)
<jhass> sure thing :)
weaksauce has joined #ruby
ur5us has quit [Remote host closed the connection]
ur5us has joined #ruby
shakes has joined #ruby
cnsvc has joined #ruby
ellcs has joined #ruby
ellcs has quit [Ping timeout: 268 seconds]
deadk is now known as e
Sina has quit [Ping timeout: 240 seconds]
peteretep has quit [Read error: Connection reset by peer]
podman has quit [Read error: Connection reset by peer]
JayDoubleu has quit [Read error: Connection reset by peer]
graphicsv has quit [Read error: Connection reset by peer]
KnownSyntax has quit [Read error: Connection reset by peer]
rann has quit [Write error: Connection reset by peer]
peteretep has joined #ruby
podman has joined #ruby
coffeejunk has quit [Ping timeout: 240 seconds]
rann has joined #ruby
KnownSyntax has joined #ruby
graphicsv has joined #ruby
JayDoubleu has joined #ruby
coffeejunk has joined #ruby
Sina has joined #ruby
<nakilon> openstruct,"Is there a mathy way to tell" -- I guess the number has to be a reducable to a fraction (x/y), where y = 2^z
<nakilon> like 3/4, 136419/1024, etc.
<nakilon> the more digits in your number, the less likely the denominator is the power of two
<nakilon> and not only that; the difference between the lowest bit and the highest significant but must be within the machine bitness: in 1/2 + 1/(2^65) -- you won't get the 999999 thing, but you'll lose the precision
ivzhh has joined #ruby
wimpog has joined #ruby
wimpog has quit [Client Quit]
Rudd0 has quit [Ping timeout: 265 seconds]
openstruct has quit [Ping timeout: 260 seconds]
carbone5 has joined #ruby
ur5us has quit [Ping timeout: 264 seconds]
ivzhh has quit [Remote host closed the connection]
cnsvc has quit [Quit: WeeChat 2.9]
powerhouse has quit [Remote host closed the connection]
elcontrastador has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
elcontrastador has joined #ruby
davispuh has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
bamdad has quit [Remote host closed the connection]
bambanx has quit [Quit: Leaving]
ivzhh has joined #ruby
kristian_on_linu has quit [Remote host closed the connection]
BTRE has quit [Read error: Connection reset by peer]
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
BTRE has joined #ruby
zacts has joined #ruby
ivzhh has quit [Remote host closed the connection]
zacts_ has joined #ruby
zacts is now known as Guest97290
zacts_ has quit [Client Quit]
zacts has joined #ruby
Guest97290 has quit [Ping timeout: 260 seconds]
carbone5 has quit [Quit: carbone5]
_whitelogger has joined #ruby
ivzhh has joined #ruby
crankharder has joined #ruby
crankharder has quit [Client Quit]
shakes has joined #ruby
swaggboi has quit [Quit: C-x C-c]
Emmanuel_Chanel has quit [Ping timeout: 272 seconds]
swaggboi has joined #ruby
Emmanuel_Chanel has joined #ruby
shakes has quit [Quit: Leaving]
zacts has quit [Quit: leaving]
chouhoulis has quit [Remote host closed the connection]
cthulchu_ has joined #ruby
Rudd0 has joined #ruby
ua has quit [Ping timeout: 256 seconds]
cthulchu_ has quit [Ping timeout: 240 seconds]
bamdad has joined #ruby
elcontrastador has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
zacts has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ChmEarl has quit [Quit: Leaving]
cliluw has joined #ruby
iNs_ has quit [Remote host closed the connection]
iNs has joined #ruby
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZU has joined #ruby
_aeris_ has quit [Remote host closed the connection]
_aeris_ has joined #ruby
bamdad has quit [Ping timeout: 240 seconds]
bamdad has joined #ruby
FastJack has quit [Ping timeout: 264 seconds]
FastJack has joined #ruby
bamdad has quit [Ping timeout: 240 seconds]
bamdad has joined #ruby
Liothen has quit [Ping timeout: 260 seconds]
Liothen has joined #ruby
ur5us has joined #ruby
cd has quit [Quit: cd]
cliluw has quit [Ping timeout: 260 seconds]
cliluw has joined #ruby
akem has quit [Ping timeout: 260 seconds]
ap4y has quit [Ping timeout: 268 seconds]
BSaboia has joined #ruby
ua has joined #ruby
dionysus69 has joined #ruby
ellcs has joined #ruby
ellcs has quit [Ping timeout: 268 seconds]
crankharder has joined #ruby
dionysus69 has quit [Ping timeout: 246 seconds]
ur5us has quit [Ping timeout: 264 seconds]
cliluw has quit [Ping timeout: 260 seconds]
imode has quit [Ping timeout: 240 seconds]
cliluw has joined #ruby
crankharder has quit [Ping timeout: 264 seconds]
Tuor has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
Tuor has joined #ruby
mniip has quit [Ping timeout: 600 seconds]
_whitelogger has joined #ruby
nofxx_ has joined #ruby
nofxx has quit [Ping timeout: 268 seconds]
mniip has joined #ruby
BSaboia has quit [Quit: This computer has gone to sleep]
ta has quit [Ping timeout: 258 seconds]
ta has joined #ruby
rippa has joined #ruby
ta has quit [Ping timeout: 260 seconds]
ta has joined #ruby
akem has joined #ruby
cliluw has quit [Ping timeout: 264 seconds]
TCZ has joined #ruby
chouhoulis has joined #ruby
TCZ has quit [Quit: Leaving]
chouhoulis has quit [Ping timeout: 260 seconds]
iamgr00t has quit [Quit: afk]
iamgr00t has joined #ruby
alexherbo2 has joined #ruby
silverdust has joined #ruby
akem has quit [Quit: Leaving]
TCZ has joined #ruby
iamnix has joined #ruby
VicMackey has joined #ruby
<VicMackey> Hello everyone! I came yesterday seeking help because when installing Rails, Nokogiri was giving me a compilation error. I've fixed the issue: it is a bad idea to compile Ruby, then do a full dist-upgrade, and then try to install some other stuff. So the issue was that. Thanks for the help :)
<VicMackey> After the full dist-upgrade I removed rbenv completely as jhass suggested, and reinstalled. Now Ican install gems normally :) Thanks!
iamgr00t has quit [Quit: afk]
iamnix_ has joined #ruby
iamgr00t has joined #ruby
iamnix has quit [Ping timeout: 260 seconds]
elcontrastador has joined #ruby
ChmEarl has joined #ruby
ua has quit [Ping timeout: 264 seconds]
zacts has quit [Quit: leaving]
iamnix_ has quit [Read error: Connection reset by peer]
VicMackey has quit [Quit: Konversation terminated!]
zacts has joined #ruby
bromps has joined #ruby
elcontrastador has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
ua has joined #ruby
zacts has quit [Quit: leaving]
silverdust has quit [Ping timeout: 264 seconds]
bmurt has joined #ruby
BSaboia has joined #ruby
TCZ has quit [Quit: Leaving]
orbyt_ has joined #ruby
silverdust has joined #ruby
iamgr00t has quit [Quit: afk]
BSaboia has quit [Quit: This computer has gone to sleep]
iamgr00t has joined #ruby
BSaboia has joined #ruby
adu has joined #ruby
silverdust has quit [Ping timeout: 260 seconds]
burgestrand has joined #ruby
cd has joined #ruby
iamnix has joined #ruby
silverdust has joined #ruby
mozzarella has quit [Quit: WeeChat 2.8]
iamnix has quit [Read error: Connection reset by peer]
burgestrand has quit [Quit: burgestrand]
burgestrand has joined #ruby
burgestrand has quit [Client Quit]
adu has quit [Quit: adu]
silverdust has quit [Ping timeout: 260 seconds]
zacts has joined #ruby
silverdust has joined #ruby
elcontrastador has joined #ruby
silverdust has quit [Ping timeout: 260 seconds]
silverdust has joined #ruby
banisterfiend has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
zacts has quit [Ping timeout: 272 seconds]
vondruch_ has joined #ruby
vondruch_ is now known as vondruch
banisterfiend has quit [Read error: Connection reset by peer]
vondruch has quit [Quit: vondruch]
mozzarella has joined #ruby
dionysus69 has joined #ruby
akem has joined #ruby
chouhoulis has joined #ruby
axsuul has quit [Ping timeout: 240 seconds]
zacts has joined #ruby
Rudd0 has quit [Ping timeout: 272 seconds]
ellcs has joined #ruby
kristian_on_linu has joined #ruby
weaksauce has quit [Ping timeout: 268 seconds]
imode has joined #ruby
mjacob has joined #ruby
zacts has quit [Quit: leaving]
silverdust has quit [Ping timeout: 240 seconds]
silverdust has joined #ruby
kindwindfall has joined #ruby
silverdust has quit [Ping timeout: 265 seconds]
adu has joined #ruby
adu has quit [Quit: adu]
adu has joined #ruby
kindwindfall_ has joined #ruby
kindwindfall has quit [Ping timeout: 258 seconds]
kindwindfall__ has joined #ruby
kindwindfall_ has quit [Ping timeout: 260 seconds]
iamnix has joined #ruby
alexherbo20 has joined #ruby
alexherbo2 has quit [Ping timeout: 258 seconds]
alexherbo20 is now known as alexherbo2
cd has quit [Quit: cd]
powerhouse has joined #ruby
iamnix has quit [Read error: Connection reset by peer]
cd has joined #ruby
ellcs has quit [Ping timeout: 268 seconds]
silverdust has joined #ruby
<isene> How do I extract a path such as "/home/geir/test" from a string such as "\\e[38;5;238m 33\\e[0m \\e[38;5;231m/home/geir/test\\e[0m\\n"?
<isene> As in - removing any garbage before the first "/" and including everything that would be part of the path, removing any garbage at the end?
weaksauce has joined #ruby
<leah2> str[/\/[^\e]*/]
ellcs has joined #ruby
<isene> leah2: I did try that, but that yields "/home/geir/test\\e[0m\\n"
<leah2> you have the \e escaped twice somehow
<leah2> sure that is intented?
<leah2> try [^\\]
<isene> leah2: That is intended, but your last suggestion did work. Thanks :-)
<leah2> that will not allow other \ in the path tho
<leah2> you may or not care about that
ellcs has quit [Ping timeout: 268 seconds]
<isene> leah2: No, that is quite OK
ur5us has joined #ruby
silverdust has quit [Ping timeout: 264 seconds]
howdoi has joined #ruby
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
ap4y has joined #ruby
Azure has quit [Read error: Connection reset by peer]
Azure has joined #ruby
silverdust has joined #ruby
ur5us has quit [Remote host closed the connection]
ur5us has joined #ruby
silverdust has quit [Ping timeout: 272 seconds]
Pierreb has joined #ruby
adu has quit [Quit: adu]
ap4y has quit [Quit: WeeChat 2.9]
ap4y has joined #ruby
<Pierreb> Standard time for my server is UTC and i want to display something in Central American time -6 hours. anyone know how to do that? https://dpaste.org/mOy7
SeepingN has joined #ruby
<orbyt_> `.getlocal("-06:00")` should work Pierreb
weaksauce has quit [Quit: Textual IRC Client: www.textualapp.com]
<orbyt_> Does anyone know of a Ruby equivalent of Python's PRAW reddit wrapper?
<Pierreb> that worked great orbyt_, thank you very much
TCZ has joined #ruby
Rudd0 has joined #ruby
silverdust has joined #ruby
weaksauce has joined #ruby
teardown has quit [Ping timeout: 240 seconds]
silverdust has quit [Ping timeout: 258 seconds]
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
TCZ has quit [Quit: Leaving]
davispuh has joined #ruby
neshpion has joined #ruby
silverdust has joined #ruby
<neshpion> in pry, when i do something like `Math.methods` the color formatting works just fine. I see in `pstree` that `pry` is invoking `less`. But when i run this same command in `pry` with the env variable PAGER=/usr/bin/less, the formatting doesn't display correctly in less and it shows the actual character escape sequences like [ESC] etc.
silverdust has quit [Ping timeout: 260 seconds]
teardown has joined #ruby
alexherbo2 has quit [Read error: Connection reset by peer]
davispuh has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
alexherbo2 has joined #ruby
davispuh has joined #ruby
howdoi has quit [Quit: Connection closed for inactivity]
akem has quit [Quit: Leaving]
powerhouse has quit [Read error: Connection reset by peer]
powerhouse has joined #ruby
ellcs has joined #ruby
kristian_on_linu has quit [Remote host closed the connection]
mbrndtgn has quit [Quit: The Lounge - https://thelounge.chat]
mbrndtgn has joined #ruby
ellcs has quit [Ping timeout: 268 seconds]
adu has joined #ruby
silverdust has joined #ruby
thecoffemaker has quit [Ping timeout: 265 seconds]
thecoffemaker has joined #ruby