ChanServ changed the topic of #picolisp to: PicoLisp language | Channel Log: https://irclog.whitequark.org/picolisp/ | Check also http://www.picolisp.com for more information
jibanes has quit [Ping timeout: 260 seconds]
jibanes has joined #picolisp
orivej has joined #picolisp
jibanes has quit [Ping timeout: 240 seconds]
jibanes has joined #picolisp
<Regenaxer> Hi aw-, pil21 now uses the readline library, so it is under your control
<Regenaxer> This is my ".inputrc": http://ix.io/2AgE
<aw-> Regenaxer: i see! that's really wonderful
<aw-> can you include that file in the release?
orivej has quit [Ping timeout: 240 seconds]
<aw-> sad to say, i never knew about ~/.inputrc
<aw-> Regenaxer: can you help me fix this function? I wrote something which converts an unsigned integer to a signed integer.. and it works but i feel like there's a better/easier way
<aw-> : (to-signed 32769)
<aw-> -> -32767
<Regenaxer> I think better not to include, people use too individual configurations. The docs should mention it, links to official docs perhaps
<Regenaxer> yeah, conversion to strings in hex is awful overhead
<Regenaxer> It is a simple addition
<aw-> ok
<Regenaxer> when > 32767 then subtract 32768
<aw-> ok but i need to know how many bytes are used to store 32767 first?
<aw-> i want this to work with arbitrary size integers
<Regenaxer> yes, this is always needed for 2-compl
<Regenaxer> makes only sense in context of a word length
<Regenaxer> 32769 is a positive number in 32 bits
<Regenaxer> Wrong above btw, I meant to subtract 65536
<Regenaxer> Subtract (** 2 <wordsize>)
<aw-> ok then what?
<Regenaxer> ?
<aw-> wait
<aw-> ok i rewrote it
<aw-> wait that can't be right
<Regenaxer> yep
<aw-> hmmmm
<Regenaxer> As I say, it makes no sense
<Regenaxer> Think what 2-complement *means*
<aw-> yes it makes no sense
<aw-> yeah i've been thinking for two days now, thats why i ask for your help
<Regenaxer> Sadly I can't help ;)
<Regenaxer> If it would make sense, pil would certainly have a primitive for it
<Regenaxer> but pil has no fixed word size
<Regenaxer> so there is no 2-compl
<Regenaxer> and no bitwise negation
<aw-> why not?
<Regenaxer> in an 8 bit number, not(1) is FF, right?
<Regenaxer> in 16 bits it is FFFF
<aw-> yes
<Regenaxer> but in pil?
<Regenaxer> it is an infinite number of Fs
<Regenaxer> whole memory
<Regenaxer> and more
<aw-> what? why? the number 15 is an 8-bit number
<aw-> that is known
<aw-> it's not infinite
<Regenaxer> in pil 15 is *not* an 8-bit number
<Regenaxer> it *fits* into 8 bits
<Regenaxer> but it fits also into 32 bits
<aw-> ok.. but if you look at 15 then you can determine that it fits in 8-bits therefore you can know how "big" it is
<aw-> so you're saying in picolisp I can't negate the number 15 and obtain its 2s complement? but i wrote a function that does it, works fine
<Regenaxer> You can define your own math, yes
<Regenaxer> but what sense does it make?
<aw-> well if I want to send a negative number over a network
<aw-> i need to send a series of bytes
<aw-> how would you do it?
<Regenaxer> or you send a sign bit, as PLIO does
<aw-> sign bit or sign byte?
<Regenaxer> a bit is enough
<Regenaxer> see PLIO
<aw-> i'm using 2s complement to encode the sign bit in the MSB
<aw-> that's why _everyone_ does
<Regenaxer> so if you send FF, is it -1 or 255?
<aw-> that' what everyone does
<Regenaxer> YES, BUT WITH A DEFINED WORD SIZE
<Regenaxer> FFFF is -1 in 2 bytes
<Regenaxer> but 65535 in 32 bytes
<aw-> ok... just as an example, if I want to send 65535, i would send 3 bytes: (2 255 255)
<Regenaxer> why the '2'?
<Regenaxer> you pass the word length?
<aw-> size of the integer
<Regenaxer> then we are back
<aw-> yes
<Regenaxer> so you KNOW it
<Regenaxer> Subtract (** 2 <wordsize>)
<aw-> ok so to obtain the wordsize, I am doing (size (>> 1 Int))
<Regenaxer> Sending a sign bit is a lot less overhead though
<aw-> ok let's take the integer -32767
<Regenaxer> Just send a sign bit and the absolute number
<Regenaxer> look at PLIO, all solved
<Regenaxer> -2 is sent as 3
<Regenaxer> +2 is sent as 2
<Regenaxer> -4 is sent as 5
<Regenaxer> etc
<Regenaxer> no
<aw-> that's strange
<Regenaxer> -4 is sent as 9
<aw-> non-standard
<Regenaxer> the number doubled plus sign bit
<aw-> -2 should be sent as 254 in 2s complement
<Regenaxer> a 2-compl of a 3-byte number is also no standard
<Regenaxer> ok, do as you like
<aw-> it's not my choice
<aw-> every programming language and platform uses 2s complement
<aw-> i cant tell everyone to start using PLIO
<Regenaxer> No
<Regenaxer> I meant the algorithm
<aw-> if I "send PLIO" then the receiver needs to "understand PLIO" as well
<Regenaxer> PLIO makes sense if you have symbols and lists etc
<Regenaxer> Please just do it
<Regenaxer> what is the problem?
<aw-> but i'm not sending symbols or lists
<aw-> i'm sending integers
<Regenaxer> grrrrrrrrr
<aw-> i use PLIO in lots of places
<Regenaxer> I'm talking to a wall
<aw-> no, you're trying to force something on me which doesn't even apply to my use-case
<Regenaxer> Just do it. Subtract the word size
<Regenaxer> bye
Regenaxer has left #picolisp [#picolisp]
<aw-> i don't understand why I would use PLIO to send data to non-picolisp programs, particularly since the PLIO algorithm isn't even documented and nobody except Regenaxer knows how to implement it
<aw-> useless discussion
Regenaxer has joined #picolisp
aw- has left #picolisp [#picolisp]
orivej has joined #picolisp
orivej has quit [Ping timeout: 265 seconds]
orivej has joined #picolisp
<beneroth> I guess aw- didn't saw the C implementation.
<Regenaxer> Well, I did not recommend to use PLIO
<Regenaxer> Just encode numbers
<Regenaxer> shift left and add 1 if negative
<Regenaxer> (or (>> -1 N) (if (lt0 N) 1 0))
<Regenaxer> Building a 2-compl is much more expensive for a variable word size. Exponentation.
<beneroth> yeah. though maybe he needs to be compatible with an existing protocol
<Regenaxer> Not clear, it seems he is free within certain boundaries
<Regenaxer> In any case it is strage to hav 2-complement numbers with e.g 3 byyes
<Regenaxer> bytes
<beneroth> T
<beneroth> but well.. many things don't make sense :/
<Regenaxer> yes, very many
m_mans has joined #picolisp
m_mans has quit [Client Quit]
jibanes has quit [Ping timeout: 240 seconds]
jibanes has joined #picolisp