<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>
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.
<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…]
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
<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]