r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

Henrik
16-Oct-2005
[2353x3]
pekr, it calculates date, not time difference that way. you need 
to:

start: now/time/precise wait 5 print (now/time/precise - start)
there is an interesting "bug" that way: you'll be shifted back 24 
hours if the difference is calculated across midnight.
it would be nice if it calculated the complete time and date difference
Graham
16-Oct-2005
[2356]
Use 'difference
Henrik
16-Oct-2005
[2357x2]
ah... thanks
(but IMHO not particularly obvious)
Graham
16-Oct-2005
[2359]
You pick up these things by talking to people ... not reading obscure 
manuals :)
Henrik
16-Oct-2005
[2360]
and then you write them down in wikibooks :-)
Louis
16-Oct-2005
[2361]
Geomol, let me see what I can do myself first. I like to know what 
is happening in my scripts.
Geomol
17-Oct-2005
[2362]
Isn't this a bit strange?
>> 3 // 3
== 0
>> 3 // 2
== 1
>> 3 // 2.6
== 0.4
>> 3 // 3.4
== 3.0
Sunanda
17-Oct-2005
[2363]
Very!
Ladislav
17-Oct-2005
[2364]
yes, it is, try MOD and MODULO functions, if you need a different 
behaviour
Geomol
17-Oct-2005
[2365]
Same behaviour:

>> mod 3 3
== 0
>> mod 3 2
== 1
>> mod 3 2.6
== 0.4
>> mod 3 3.4
== 3.0
Ladislav
17-Oct-2005
[2366x2]
right, in these specific cases, otherwise the behaviour may differ.
what would did you expect to get?
Geomol
17-Oct-2005
[2368x2]
I guess, I was just surprised, that it worked with decimals. Then 
it can maybe be argues, if 3 // 3.4 should return an integer or a 
decimal.
argues = argued
Ladislav
17-Oct-2005
[2370]
the definition is as follows: if r = a // b, then a - r // b should 
be zero
Sunanda
17-Oct-2005
[2371]
Been thinking about it too....It is surprsing, but does make sense.
It's returning the remainder:
3 // 2.6 --> remainder is 0.4
3 // 3.4 --> remainder is 3
Ladislav
17-Oct-2005
[2372]
other formulation: if r = a // b, then a = some-integer * b + r
Geomol
17-Oct-2005
[2373x2]
In rebcode, I guess the upcode rem is remainder. It works a little 
different there:
set a 3
rem a 3

now a is 0. If doing this:
set a 3.0
rem a 3

then a is 3.0.
I guess, it has to do with the internal floating-point representation 
of numbers.
Gabriele
17-Oct-2005
[2375]
rebcode's rem does *not* support decimals.
Pekr
21-Oct-2005
[2376x2]
will it be possible to do easy types conversion with rebcode? regard 
me being stupid, but I regard following being  bug or at least inconsistence:

type? #{77}
== binary!    ; so no excuse it is a string later!

to-integer #{77}
== 119

to-binary to-integer #{77}
== #{313139}
If pure functions which serve datatype conversion work one way, it 
is imo inconsistent that it does not work the same way in the reverse 
mode ....a
Rebolek
21-Oct-2005
[2378x3]
If you want to convert a number to binary, number must be enclosed 
in brackets, to binary! [119] , not to binary! 119
so your example should look like:
to binary! reduce [to integer! #{77}]
== #{77}
Pekr
21-Oct-2005
[2381x2]
we are not converting here string of "119" values, but integer!
why?
Rebolek
21-Oct-2005
[2383x3]
that's what's written in documentation
I don't know the reason
And you cannot convert numbers bigger than 255
Pekr
21-Oct-2005
[2386]
I said no excuses or silly walkarounds. We are converting integer. 
Take your calculator and look how it converts it ;-)
Rebolek
21-Oct-2005
[2387x2]
to binary! [256]
== #{00}
This is not a workaround, that's in the documentation :)
Pekr
21-Oct-2005
[2389]
Kru - interesting example with integer in the block, but even more 
twisted imo :-)
Rebolek
21-Oct-2005
[2390x2]
http://rebol.com/docs/core23/rebolcore-16.html#section-2.1
To convert an integer into its binary value, pass it in a block
Pekr
21-Oct-2005
[2392x2]
so we take binary as an argument, convert it to integer. Then we 
take exactly the same integer, and convert it back to binary and 
we get different result? :-))
It is like doing 3 * 7 = 21 on calculator, then pressing /, 7, enter, 
and not getting back to 3!
Rebolek
21-Oct-2005
[2394]
I don't understand what do you mean. If you've got integer less than 
256, you'll get same result
Ladislav
21-Oct-2005
[2395]
Pekr: why don't you check RAMBO and put it there (if not already 
present)?
Pekr
21-Oct-2005
[2396x3]
I am far from being expert in assembler etc., but imo the proof of 
misconception in the first place is, that it has to be explicitly 
stated in the docs. Imo it is because naturally one would expect 
different result ... :-)
Ladislav: well, because maybe it is intended? We have it this way 
for ages, lots of code relies on it!
and because I know my knowledges are limited here, I ask gurus for 
some sane explanation of concept behind such logic, maybe there is 
one?
Ladislav
21-Oct-2005
[2399]
take it as my advice
Pekr
21-Oct-2005
[2400]
ok, I just wanted to discuss it here first, to not flood Rambo by 
unnecessary input ....
Ladislav
21-Oct-2005
[2401]
It may be already there, though
Pekr
21-Oct-2005
[2402]
so, direct question - do you personally think current state is ok 
from "language purity" pov? :-)