slipstre1m-- has quit [Read error: 110 (Connection timed out)]
smimou has joined #ocaml
bluestorm has quit [Remote closed the connection]
Skal has joined #ocaml
slipstream has quit [Read error: 104 (Connection reset by peer)]
slipstream has joined #ocaml
_JusSx_ has quit [Read error: 110 (Connection timed out)]
<dark_light>
what is the diff between 2 * - 1 and 2 * ~- 1? the first multiply the int 2 by -1 and the second negates 1 and then multiply the int 2 by the negative of 1 (that is -1) ?
<dark_light>
i am asking it because 2 * - 1 works besides the - is distant from the -1 (it shouldn't be -1?)
<mellum>
"-" is the binary minus, or can be applied to literals like 1. "~-" is unary minus.
<mellum>
So for 1, it doesn't matter, but for x it would.
<mellum>
(at least I think)
<pango>
it solves problems in other contexts (f -1 vs. f ~-1)
<pango>
without ~- you have to use f (-1)
<mellum>
right. I knew it was to resolve some ambiguity :)
<mellum>
although I tend to write f (-1) in that case
Muelation`awaY was kicked from #ocaml by Banana [Banana]
Muelation`awaY has joined #ocaml
<zmdkrbou>
apfffffffff auto-rejoin
<mikeX>
hahahah
<Banana>
...
Muelation`awaY was kicked from #ocaml by Banana [Banana]
<Banana>
still got it.
<Banana>
Now i can go back to sleep for another year.
<mikeX>
lol
<Banana>
Does this guy actually speak here or not ?
<Banana>
(aka, is he worth unbanning ?)
<dark_light>
why signed ints and "normal" ints (the ints of C p. example) can both store the same number of numbers? signed ints shouldn't have more "space"?
<dark_light>
Banana, i don't know, but i think if someone explain him the channel don't likes away messages he would stop
<bluestorm>
nope
<bluestorm>
dark_light,
<dark_light>
bluestorm, so why use signed ints?
<bluestorm>
the sign bit take one bit from the total space
<dark_light>
Hm..
<bluestorm>
hum
<bluestorm>
but you have two different numbers with the sign bit
<bluestorm>
so totally it's the same
<bluestorm>
dark_light, we use signed ints in order to have negative integers
<bluestorm>
(did i say something stupid ? It seems the answer is so trivial...)
<dark_light>
well, the normal C ints have negative ints, but it seems not be "signed"
<dark_light>
there are sign bit on regular C ints?
<bluestorm>
yes
<bluestorm>
negative int must have a sign bit
<bluestorm>
how would you now it is negative ?
<bluestorm>
+k
<dark_light>
well, i though.. let say a byte.. 0000 0001 is -128, 0000 0010 is -127 .. and 1111 1111 is 127.. you know?
<pango>
unsigned 32 bit ints are in range 0 .. 2^32-1, signed in range -2^31 .. 2^31-1
<pango>
no matter what, with 32 bits you can store 2^32 different states
<mellum>
well, that depends on the architecture
<dark_light>
pango, hmm, year, i got it
<dark_light>
0000 0001 differs to 1111 1111 more than a bit, bluestorm
<dark_light>
yeah*
<mellum>
ah, never mind what I was saying
<bluestorm>
two bits :p
<dark_light>
no, seven :P
<bluestorm>
nope
<bluestorm>
1111 1111 + 10 = 0000 0001
<bluestorm>
127 + 1 = -128
<bluestorm>
127 + 2 = -127
<bluestorm>
127 + 3 = -126 ...
<dark_light>
the first to seventh (i don't actually know if this word exists) bit in my -127 is filled with zeroes, and in my 127 is filled with ones
<bluestorm>
hum
<dark_light>
you got what i am trying to say? explaining on english is just hard for me=(
<bluestorm>
i see what you mean
<bluestorm>
i think
<dark_light>
so i think the int and the signed int of C is quite different
<dark_light>
maybe the signed int helps on calculating absolute values
<dark_light>
-0 and +0 are actually different numbers, aren't? there are more negative numbers than positives.. so the -0 wasn't lost and considered equal to +0
<pango>
that's answered in the wiki page
<Banana>
dark_light: there is only one representation for 0. ( 0000 0000).
<dark_light>
wow, it's more complicated i ever imagined
<Banana>
dark_light: the whole thing is in two's complement encoding for negative numbers.
<Banana>
dark_light: yes but it makes things easier for computers :)
jo_l_apache has joined #ocaml
<dark_light>
easier? if you are saying..
<Banana>
dark_light: i meant more uniform.
<Banana>
consider the enconding where 0 xxx xxxx are positive numbers and 1 xxx xxxx are negative (that's what you were thinking right ?).
<Banana>
and try writing the algorithm for the addition.
<dark_light>
Banana, that was i were thinking
<dark_light>
and, hmmmmmmmmmmmmmm..
<dark_light>
yeah
<dark_light>
;
<dark_light>
:)
<Banana>
first this is bad because you have +0 and -0, so you waste 1 value.
<Banana>
and there was a time, (in a galaxy far far away) when that kind of thing was a big deal.
<dark_light>
hmmmmmmm
<dark_light>
Banana, why signed ints are better than normal ints?
<dark_light>
or. why ocaml uses them?
<Banana>
i'm not sure what you mean by normal ints...
<dark_light>
well..
<Banana>
unsigned ?
<dark_light>
no
<dark_light>
"well, i though.. let say a byte.. 0000 0001 is -128, 0000 0010 is -127 .. and 1111 1111 is 127.. you know?"
<Banana>
ha.
<Banana>
you cannot do that.
<Banana>
because it doesn' scale well.
<dark_light>
Banana, int's aren't counted that way?
<dark_light>
hmmmmmmm
<dark_light>
so this model is a.. char? :)
<dark_light>
chars is counted in the order, but ints aren't?
<Banana>
?
<pango>
see "how it works" in the wiki page
<dark_light>
why it works?
<pango>
why it works, yes
<dark_light>
the mathmatics there is so complex. i am a bit.. sleeply now
<Banana>
dark_light: yes read carefully the wiki page, but with what you said you would have 0000 0000 = 0, 0000 0001 = -128, 0000 0010 = -127 ... ?
<Banana>
if i understand correctly ?
<dark_light>
Banana, yes
<Banana>
you cannot do that.
<dark_light>
the char type of C is counted "in the order" (i meant.. the first character is 0000 0000, the second is 0000 0001..)
<Banana>
you are on a byte, so you say ok, 0000 0001 is -128.
<dark_light>
an int on a byte aren't counted one after another?
<Banana>
but now you want to encode 16 bytes ?
<pango>
it's not unusual that mathematics gives answers to problems involving numbers
<Banana>
you have 0000 0000 0000 00010 is -128 ?
<Banana>
or is it -65536 ?
<dark_light>
Hmmmmm.. yeah
<dark_light>
0000 0000 0000 00010 would move to -65536
<pango>
(or is it ? it's also a source of most of those problems too ;) )
<dark_light>
pango, i don't understand what you meant
jo_l_apache has quit ["leaving"]
<Banana>
dark_light: ok so when you add -128 (byte) to a 16 bits word you have to do a conversion.
<dark_light>
Hmmmmmmm...
<pango>
dark_light: if you're interested in numbers, there's no work around mathematics
<Banana>
dark_light: to start with, you should REALY forget about types (i cannot belive i'm actually saying that here ;)).
<mellum>
pango: of course not. Who'd ever be able to count to 10 without understanding the Peano axioms?
<Banana>
dark_light: they are just conventions.
<Banana>
forget about chars, ints, and such.
<dark_light>
pango, you are right, but i was interested on concepts because i am.. how could i say? sleeply
<dark_light>
my eyes is closing right now
<dark_light>
bookmarked:)
Snark has quit ["Leaving"]
<pango>
after a nap you can have a look at "rings" in algebra books too :)
<twobitsprite>
is there any overhead for using "fun" over "function" when the function is only taking one argument anyways?
<pango>
twobitsprite: have you looked at generated asm ?
<twobitsprite>
pango: not yet... I'm not the keenest on asm, so I was hoping someone could tell me...
<mellum>
twobitsprite: no
<Banana>
no.
<Demitar>
If you're wondering about the overhead of those two syntaxes you're probably optimizing way too early anyway. :)
Anarchos has joined #ocaml
<twobitsprite>
Demitar: I was just curious...
<Demitar>
Good. :)
* Demitar
has mostly puts "optimizations" off to code cleanup and the occacional memoization these days. :)
<twobitsprite>
I'm a big fan of doing TheSimplestThingThatCouldPossiblyWork and if it's way too slow, I'll tweek a few things until its FastEnough(tm)
<Banana>
hum...
<Demitar>
Yes, simple code is usually fast code. :)
<twobitsprite>
but I figured there was no harm in typing out "ction" if it would make a significant difference...
<Demitar>
I know you didn't mean to, but you confused "simple code" and "compact code" in that sentence. :)
<Anarchos>
a naive recursive fibonacci is far form the fastest ...
<Demitar>
Anarchos: And how often do you write your own fibonacci in a normal application? :)
<dark_light>
twobitsprite, me too, but my code instead is quite complex.=(
<mellum>
function calls are optimized quite well in Ocaml (unlike almost everything else).
<twobitsprite>
dark_light: always keep in mind the differences between complexity and complication... complex is good, complicated is bad
<twobitsprite>
mellum: are the authors slack on optimizations?
<Anarchos>
Demitar : 1/ U(1978) ??
<Banana>
twobitsprite: there is a difference however, you can put pattern matching branches after function, you cannot after fun.
<Demitar>
What I prioritize most is actually well named variable, maintenance is usually the tricky part in the end.
<mellum>
twobitsprite: It's not the main focus.
<twobitsprite>
Banana: I realize this...
<dark_light>
i simply doesn't program on levels. the simple things on a part, the advanced features on another. i mix everything
<pango>
twobitsprite: they're fans of doing TheSimplestThingThatCouldPossiblyWork
<Anarchos>
pango the logical team is not part of this sect though ;)
<twobitsprite>
pango: I tend to do the SimplestThing because I expect my compiler to take care of the complications, so that's fine with me...
<bluestorm>
hum
<Demitar>
pango: I might not be such a rabid follower actually, I'm more of a TheQuickestThingICanComeUpWithAndI'llOptimize"Later". :)
<bluestorm>
imho you like TheAwfulJavaNotation too much
<twobitsprite>
bluestorm: well... I intended it as WikiNotation...
<mellum>
CamlCase ;-)
<bluestorm>
Ocaml guidelines are very useful, and they use a good notation :p