TCZ has quit [Quit: Leaving]
reepca has quit [Read error: Connection reset by peer]
reepca has joined #forth
boru` has joined #forth
boru has quit [Disconnected by services]
boru` is now known as boru
<MrMobius> quiet in here again
<MrMobius> ive been watching the svfig videos
<MrMobius> theres some pretty good stuff on there
WickedShell has quit [Remote host closed the connection]
<tabemann> hey
<MrMobius> whats up tabemann
<crc> I'm sure the channel will get active again...
<tabemann> not a whole lot
<tabemann> just wondering how I can convert some C code that I was given into Forth
<tabemann> for implementing log2
<tabemann> it's supposed to be faster than how I'm currently implementing ln (and ln can be implemented with log2), but I can't say I really understand the code
<MrMobius> is it cordic by chance?
<MrMobius> converting is hard without really understanding everything it's doing
<MrMobius> I think you need an extra division and multiply to convert logs iirc
<tabemann> the method I'm using isn't CORDIC
<tabemann> the thing is that it involves calculating e^x at each step, which is apparently expensive
<MrMobius> oh hmm
<MrMobius> how are you dong e^x then if not cordic?
<MrMobius> taylor expansion or something?
<tabemann> I honestly don't remember which algorithm I am using, because this is based on older code I wrote for a different Forth implementation
<tabemann> I'd have to look up the expansions, but I wouldn't be suprised if it were Taylor or Maclaurin
Keshl has quit [Read error: Connection reset by peer]
Keshl has joined #forth
Keshl has quit [Read error: Connection reset by peer]
Keshl has joined #forth
gravicappa has joined #forth
<KipIngram> What are we computing?
<KipIngram> Sorry - coming in late here.
<KipIngram> Ah - log2?
reepca has quit [Ping timeout: 256 seconds]
rdrop-exit has joined #forth
Lord_Nightmare has quit [Quit: ZNC - http://znc.in]
Lord_Nightmare has joined #forth
<rdrop-exit> log2 Floor of binary logarithm. *** N.B. log2 of 0 is -1. ***
<rdrop-exit> clog2 Ceiling of binary logarithm. *** N.B. clog2 of 0 is 0. ***
<rdrop-exit> : log2 ( u -- n ) #lead-0s 63 \- ;inline
<rdrop-exit> : clog2 ( u -- u' ) dup 0<> + #lead-0s 64 \- ;inline
<rdrop-exit> (assuming 64-bit Forth)
rdrop-exit has quit [Quit: Lost terminal]
xek_ has joined #forth
gravicappa has quit [Ping timeout: 272 seconds]
xek_ has quit [Ping timeout: 272 seconds]
gravicappa has joined #forth
gravicappa has quit [Ping timeout: 256 seconds]
dys has joined #forth
proteusguy has quit [Ping timeout: 256 seconds]
proteusguy has joined #forth
xek has joined #forth
reepca has joined #forth
xek has quit [Ping timeout: 272 seconds]
reepca has quit [Ping timeout: 258 seconds]
reepca has joined #forth
reepca has quit [Read error: Connection reset by peer]
xek has joined #forth
TCZ has joined #forth
gravicappa has joined #forth
<KipIngram> Why do we go to the trouble to handle zero at all? Logarithms of zero aren't defined.
dave0 has quit [Quit: dave's not here]
xek has quit [Ping timeout: 272 seconds]
TCZ has quit [Quit: Leaving]
Zarutian_HTC has quit [Ping timeout: 258 seconds]
xek has joined #forth
TCZ has joined #forth
rdrop-exit has joined #forth
<rdrop-exit> It's just in certain cases
<rdrop-exit> it's just convenient in certain cases
<rdrop-exit> you can save one Forth instruction on clog2 if you prefer to ignore it
<rdrop-exit> it makes no difference in the floored log2
<rdrop-exit> Here's a version of ceiling log2 without the artificial value at 0:
<rdrop-exit> : clog2 ( u -- u' ) #lead-0s 65 \- ;inline
<rdrop-exit> oops that's totally wrong
<rdrop-exit> better stick with the original:
<rdrop-exit> : clog2 ( u -- u' ) dup 0<> + #lead-0s 64 \- ;inline
<rdrop-exit> feel free to ignore the pseudo values at 0 if you have no use for them
TCZ has quit [Quit: Leaving]
<rdrop-exit> The floored version is also fine as it is:
<rdrop-exit> : log2 ( u -- n ) #lead-0s 63 \- ;inline
<rdrop-exit> 2 2** Raise 2 to a power.
<rdrop-exit> 3
<rdrop-exit> 4 pwr2 Floor power of 2, round down to closest power of 2
<rdrop-exit> 5 <= <u>.
<rdrop-exit> 6
<rdrop-exit> 7 cpwr2 Ceiling power of 2, round up to the closest power of 2
<rdrop-exit> 8 >= <u>.
<rdrop-exit> 0 source Arithmetic - Powers of 2
<rdrop-exit> 1
<rdrop-exit> 2 : 2** ( 0..3f -- 1<<0..3f ) 1 swap lshift ;inline
<rdrop-exit> 3
<rdrop-exit> 4 : pwr2 ( u -- u' ) log2 2** ;inline
<rdrop-exit> 5
<rdrop-exit> 6 : cpwr2 ( u -- u' ) clog2 2** ;inline
<rdrop-exit> 7
<rdrop-exit> b
<rdrop-exit> c addressing Number of address bits needed to address a memory of
<rdrop-exit> d size <u>.
<rdrop-exit> e
<rdrop-exit> c : addressing ( u -- #bits ) clog2 ;inline
<rdrop-exit> d
<rdrop-exit> #bits Number of significant bits of <u>.
<rdrop-exit> : #bits ( u -- # ) log2 0 max 1+ ;inline
<rdrop-exit> #bytes Number of significant bytes of <u>, i.e. radix 256.
<rdrop-exit> : #bytes ( u -- # ) log2 0 max 3 rshift 1+ ;inline
<rdrop-exit> #decimals Number of significant decimal digits of <u>.
<rdrop-exit> : #decimals ( u -- # ) lg 0 max 1+ ;inline
<rdrop-exit> The definition of #decimals above makes the same assumption about the common logarithm being "pseudo" defined as -1 at zero
<rdrop-exit> good night Forthwrights
rdrop-exit has quit [Quit: Lost terminal]
Zarutian_HTC has joined #forth
gravicappa has quit [Ping timeout: 240 seconds]
proteus-guy has joined #forth
ovf has quit [Disconnected by services]
ovf_ has joined #forth
Blue_flame has quit [*.net *.split]
jimt[m] has quit [*.net *.split]
dys has quit [Ping timeout: 244 seconds]
siraben has quit [Write error: Connection reset by peer]
siraben has joined #forth
jimt[m] has joined #forth
Blue_flame has joined #forth
TCZ has joined #forth
xek has quit [Ping timeout: 246 seconds]
gravicappa has joined #forth
Zarutian_HTC has quit [Ping timeout: 256 seconds]
xek has joined #forth
dave0 has joined #forth
xek has quit [Ping timeout: 246 seconds]
X-Scale` has joined #forth
X-Scale has quit [Ping timeout: 264 seconds]
X-Scale` is now known as X-Scale
TCZ has quit [Quit: Leaving]
gravicappa has quit [Ping timeout: 246 seconds]
X-Scale` has joined #forth
X-Scale has quit [Ping timeout: 246 seconds]
X-Scale` is now known as X-Scale
lchvdlch has joined #forth
lchvdlch has left #forth [#forth]
clog has quit [Ping timeout: 260 seconds]
WickedShell has joined #forth
Zarutian_HTC has joined #forth
TCZ has joined #forth