<discocaml>
<deepspacejohn> Then get the string from the buffer
<discocaml>
<cavemon.dev> thanks
<discocaml>
<darrenldl> anadon: if you don't mind dependency on angstrom, that would be what I would do
waleee has quit [Ping timeout: 268 seconds]
<discocaml>
<barconstruction> I am having a really weird bug which lives somewhere close to the interface between OCaml and C. Is there anything that could cause a float to have a representation that C considers valid, but OCaml thinks is nan
<dh`>
no
<dh`>
most likely you are looking at the wrong bits
<discocaml>
<barconstruction> would that be like a little endian/big endian issue?
<companion_cube>
nan is valid
<companion_cube>
but yeah, might be endianess
<discocaml>
<barconstruction> What is -nan
<discocaml>
<barconstruction> Like what does that mean?
<discocaml>
<barconstruction> How do I tell if a number is equal to -nan?
<discocaml>
<barconstruction>
<discocaml>
<barconstruction> I did printf("%f",x) in the C program and it seems to have printed -nan.
<companion_cube>
equality on nan makes little sense
<discocaml>
<barconstruction> Yes, it works for me too, ok. (That is, if I just write it as a standalone C program.)
<discocaml>
<barconstruction>
<discocaml>
<barconstruction> ```
<discocaml>
<barconstruction> x=-nan
<discocaml>
<barconstruction> is nan: 1
<discocaml>
<barconstruction> is normal: 0
<discocaml>
<barconstruction> fpclassify is nan: 1
<discocaml>
<barconstruction> fpclassify is normal: 0
<discocaml>
<barconstruction> ```
<discocaml>
<barconstruction>
<discocaml>
<barconstruction> This is all what we expect, I guess. But I'm getting a different answer in the context of this C library code that's being called from my OCaml program.
<dh`>
still seems most likely to me that you're getting the wrong bits
<discocaml>
<barconstruction> Sorry, I don't really know what you mean. I asked you if you meant endianness.
<dh`>
it's not endianness, 0x0000000000001fff is also highly unlikely to be the number you're looking for (it's a subnormal/denormal)
<dh`>
what I mean is: you are copying the wrong bits somehow
<dh`>
though maybe not, the value you've got there is not an arbitrary pile of junk that happens to decode as NaN
<dh`>
except for being negative it's the default NaN you'd likely get from a meaningless operation
<discocaml>
<barconstruction> does anyone have Owl installed and want to try and reproduce this so I can see if it's just me
<discocaml>
<barconstruction> the steps to reproduce are:
<discocaml>
<barconstruction> 3. run `gamma_isf 0.292000000000000037 ~shape:0.9 ~scale:1.`
<discocaml>
<barconstruction> i'm going to bed tho it's late
Serpent7776 has joined #ocaml
_whitelogger has quit [Ping timeout: 260 seconds]
_whitelogger has joined #ocaml
GreaseMonkey has quit [Remote host closed the connection]
greaser|q has joined #ocaml
trillion_exabyte has quit [Ping timeout: 268 seconds]
trillion_exabyte has joined #ocaml
jutty has joined #ocaml
<vb>
mpc update
<vb>
oups. wrong window.
bartholin has joined #ocaml
YuGiOhJCJ has quit [Quit: YuGiOhJCJ]
chiselfuse has quit [Remote host closed the connection]
chiselfuse has joined #ocaml
troydm has joined #ocaml
wingsorc has quit [Ping timeout: 240 seconds]
chiselfuse has quit [Remote host closed the connection]
chiselfuse has joined #ocaml
chiselfuse has quit [Remote host closed the connection]
chiselfuse has joined #ocaml
troydm has quit [Quit: What is Hope? That all of your wishes and all of your dreams come true? To turn back time because things were not supposed to happen like that (C) Rau Le Creuset]
troydm has joined #ocaml
troydm has quit [Quit: What is Hope? That all of your wishes and all of your dreams come true? To turn back time because things were not supposed to happen like that (C) Rau Le Creuset]
troydm has joined #ocaml
troydm has quit [Quit: What is Hope? That all of your wishes and all of your dreams come true? To turn back time because things were not supposed to happen like that (C) Rau Le Creuset]
troydm has joined #ocaml
troydm has quit [Quit: What is Hope? That all of your wishes and all of your dreams come true? To turn back time because things were not supposed to happen like that (C) Rau Le Creuset]
troydm has joined #ocaml
troydm has quit [Client Quit]
troydm has joined #ocaml
troydm has quit [Quit: What is Hope? That all of your wishes and all of your dreams come true? To turn back time because things were not supposed to happen like that (C) Rau Le Creuset]
troydm has joined #ocaml
torretto has quit [Ping timeout: 260 seconds]
torretto has joined #ocaml
<discocaml>
<barconstruction> This was very silly code. I forgot tilde denoted bitwise complement. I have not used C in a long time. I will have to rerun this later. But I think it is
myrkraverk_ has joined #ocaml
myrkraverk has quit [Ping timeout: 240 seconds]
myrkraverk has joined #ocaml
myrkraverk_ has quit [Ping timeout: 240 seconds]
<companion_cube>
Oh no I should have seen, indeed
<companion_cube>
It's "!" for negation of course :/
myrkraverk_ has joined #ocaml
myrkraverk has quit [Ping timeout: 240 seconds]
myrkraverk_ has quit [Read error: Connection reset by peer]
myrkraverk__ has joined #ocaml
myrkraverk__ has quit [Read error: Connection reset by peer]
myrkraverk__ has joined #ocaml
myrkraverk_ has joined #ocaml
myrkraverk__ has quit [Ping timeout: 268 seconds]
myrkraverk_ has quit [Remote host closed the connection]
myrkraverk_ has joined #ocaml
myrkraverk_ has quit [Ping timeout: 272 seconds]
<discocaml>
<barconstruction> I tried it on another machine and couldn't reproduce the error so it might be something specific to my configuration.
<discocaml>
<barconstruction> The function gives the correct answer.
<discocaml>
<barconstruction> Don't worry, I asked on stack exchange and got three comments and two answers explaining the difference between bitwise negation and logical negation. (I understand the difference I just work at a place that uses Python)
<discocaml>
<limp.biskit> is using bool to indicate success a bad pattern
<discocaml>
<octachron> A possible inconvenient is that it is relatively easy to ignore the returned bool (compared to option/result/exceptions).
waleee has joined #ocaml
<discocaml>
<lukstafi> There's some language support: `assert`. When using `ignore` remember to `ignore (... : bool)`.
<companion_cube>
yes!!
<discocaml>
<limp.biskit> companion_cube: compared to (unit, unit) Result?
<discocaml>
<limp.biskit> this is adding data to a mutable structure
<companion_cube>
no I'm saying, ignore should always go with a cast
<discocaml>
<limp.biskit> ohh
<discocaml>
<limp.biskit> in this context ignoring it would be an error anyway, as a false is supposed to indicate to stop pushing or generating data
<discocaml>
<lukstafi> Raise an effect and resize the structure in the handler 😅
jutty has quit [Ping timeout: 252 seconds]
jutty has joined #ocaml
<companion_cube>
another day, another moment of sadness at stdlib's IO channels
jutty has quit [Ping timeout: 268 seconds]
jutty has joined #ocaml
jutty has quit [Quit: jutty]
jutty has joined #ocaml
trillion_exabyte has quit [Ping timeout: 264 seconds]
trillion_exabyte has joined #ocaml
jutty has quit [Quit: jutty]
troydm has quit [Ping timeout: 260 seconds]
waleee has quit [Ping timeout: 264 seconds]
Serpent7776 has quit [Read error: Connection reset by peer]
Serpent7776 has joined #ocaml
<discocaml>
<limp.biskit> another moment of sadness at stdlib in general
<dh`>
<limp.biskit> is using bool to indicate success a bad pattern
<dh`>
yes: does true mean "yes, it succeeded" or "yes, it failed"?
<dh`>
:-|
<dh`>
it can reasonably be either way, therefore it tends to create problems eventually
<discocaml>
<limp.biskit> dh`: what would the alternatives be for a function with no meaningful return value though?
gzar has joined #ocaml
<dh`>
there's always (unit, unit) Result.t
<dh`>
or unit option
<companion_cube>
[`Ok | `Ohno]
jutty has joined #ocaml
<discocaml>
<Kali> i don't think using bool is a bad pattern if the function is named appropriately and there truly is nothing to return
<companion_cube>
yeah sometimes it's clear enough
<discocaml>
<deepspacejohn> I think it depends on what "success" means
Tuplanolla has joined #ocaml
<discocaml>
<Kali> hence appropriate name
<discocaml>
<limp.biskit> i've seen other io stuff implement similar patterns, so im probably fine
<discocaml>
<limp.biskit> as far as user expectation
Serpent7776 has quit [Ping timeout: 264 seconds]
gentauro has quit [Read error: Connection reset by peer]
<discocaml>
<contextfreebeer> I don't like bool return tbh, if you really want to use the return value for selection you can do `Option.is_some` or `Result.is_ok` etc. that seems cleaner to me
gentauro has joined #ocaml
<discocaml>
<deepspacejohn> I guess it also depends on what failure means. if it's a programmer error then maybe raise an exception or return `Error "error message"`
Serpent7776 has joined #ocaml
waleee has joined #ocaml
jutty has left #ocaml [#ocaml]
nickiminjaj has joined #ocaml
wingsorc has joined #ocaml
<dh`>
also there's often a case to be made for making a private type for it
<dh`>
sometimes you see people writing stuff like (string option option, int) either and you wonder if anyone's going to be able to read it two years later
Serpent7776 has quit [Ping timeout: 252 seconds]
<discocaml>
<contextfreebeer> Lol
bartholin has quit [Quit: Leaving]
trillion_exabyte has quit [Read error: Connection reset by peer]