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

World: r3wp

[Core] Discuss core issues

Ladislav
13-Sep-2006
[5287]
every Decimal! is "molded differently" somehow, no decimal is "exactly 
molded", example: 0.1 is a decimal! , but because the decimal! values 
are IEEE754 binary floating point, 0.1 is represented as the nearest 
IEEE754 number, which is not 0.1, because IEEE754 cannot represent 
0.1 as you probably know
Anton
13-Sep-2006
[5288]
Oh, I see. So to make them loadable you would have to mold them with 
an identifier on the front, (eg.  0d0.1)
Rebolek
13-Sep-2006
[5289x3]
OK so minimal/maximal decimal! values can be molded as nearset loadable 
decimal! or not?
nearset=nearset
grr nearest :)
Ladislav
13-Sep-2006
[5292x2]
The problem is, that there is some "inaccuracy" involved and the 
inaccuracy is so high, that the molded maximum is higher than the 
IEEE754 maximum, i.e. it causes overflow
this means, that 0d0.1 does not help
Anton
13-Sep-2006
[5294x2]
That means the decimal! maximum needs to be pulled back to the highest 
value which does not cause a problem.
But I am still confused - how can it be: "decimal! values are IEEE754 
*binary* floating point"  ?  I thought decimal! where using decimal 
math ?
Ladislav
13-Sep-2006
[5296x3]
the solution is not that easy. The problem is, that if somebody gives 
a number that is higher than all representable numbers, the overflow 
*should* occur. so we may need higher accuracy instead
 I thought decimal! where using decimal math ?
 - my favourite example: 0.3 - 0.1 - 0.1 - 0.1
in decimal math the result is exactly zero as everybody knows
Anton
13-Sep-2006
[5299x4]
Of course, sorry - confused with deci!  ..... (Probably the first 
of many confusions...)
Let me read all that again...
Yes, makes sense now.
Ok, I suppose you asked this poll question because you are looking 
for a way for the highest decimal! to be load moldable and it looks 
difficult / problematic.
Ladislav
13-Sep-2006
[5303]
the problem lies in the accuracy - we would need at least 17 digits 
from mold to be able to load back
Anton
13-Sep-2006
[5304]
How many digits are molded now ?
Ladislav
13-Sep-2006
[5305]
15
Anton
13-Sep-2006
[5306]
Maybe MOLD can be more accurate, and FORM can be less accurate ?
Ladislav
13-Sep-2006
[5307]
The trouble is, that the 16-th and 17-th digits are a bit "nonsensical", 
but they are needed for this purpose
Anton
13-Sep-2006
[5308]
(and this exceptional behaviour can be only for this exceptional 
datatype ?)
Ladislav
13-Sep-2006
[5309]
yes
Anton
13-Sep-2006
[5310x2]
I'd rather have non-sensical digits than not quite orthogonal loading/molding.
I think you can't hide the quirks of the decimal!
Ladislav
13-Sep-2006
[5312]
right
Anton
13-Sep-2006
[5313]
Another idea is that both MOLD and FORM give 17 digits, and it is 
left to another function (perhaps a FORMAT mezz) to cut off the nonsensical 
digits.
JaimeVargas
13-Sep-2006
[5314x3]
Ladislav you are hitting the Serialization/Marshalling barrier. Having 
a language where there is no difference between serialized (molded 
in rebol terms) types and source code types is big plus of Rebol. 
But on the other hand it limits you when you want to marshall the 
data becuase of the assymetry introduce to maintain accuracy for 
some types like decimal.
Usually marshalled (molded) data from other languages like Objective-C, 
Smalltalk or Java is not et all readable as rebol. So this sepparation 
helps when dealing with representation issues at the cost of making 
difficult to change the binary enconding.
Is it ok to break the rule for deci!? Hmm. I'm not sure if this belongs 
to the domain of the language designer or the public opinion.
Volker
13-Sep-2006
[5317]
IMO non-loadable things should not be moldable. So in this case make 
limits on mold, so that the mold fails with such values. Reason: 
IMO under no circumstances should a save destroy values (at least 
not from the inbuild side). Better throw the last changes away with 
a "cant save, internal error" than overwrite valid data with broken 
one. Specially if rebol is a "public" format like xml, where everyone 
can send data and trigger a broken save.
Ladislav
14-Sep-2006
[5318]
Volker:the console has got a problem with non-moldable value (it 
tries to mold every result)
Anton
14-Sep-2006
[5319x4]
On further thought, I think the decision to use binary floating point 
numbers in one's program is a decision which includes the understanding 
that there will be some molding inaccuracies. Whether you try to 
print all the digits including the nonsensical final digits (which 
is inconvenient for most usage), or try to hide them (moving the 
problem to load/mold non-orthgonality), either way you must accept 
a problem.
Unfortunately, we currently don't have a non-binary alternative floating 
point type.
But that seems to me what we really want; to supplant decimal! with 
deci!  (Anyone disagree ?)
What I'm trying to say is: I would be happy for the current molding 
of decimal! to remain as it is, if I had a deci! type that I could 
use instead.
Volker
14-Sep-2006
[5323x2]
You have always inaccuracies in theory. In practice all have IEEE, 
but in theory its what the c-compiler uses. If some software-emulation 
thinks something else works faster, sending data there is anaccurate.
LAdislav: Fix the console. Or at least a check 'reloadable? , which 
as meazzine molds, loads and checks for equality, and without to 
much overhead.
Ladislav
14-Sep-2006
[5325]
Fix the console
 - how would you like it to be fixed?
Volker
14-Sep-2006
[5326x3]
Good question. First thought was: report error. Second thought an 
option to mold, mold/always, and console uses that.
default should be "better error than sorry" for 'save-related things 
IMHO, a dont-bother option would be ok.
I am very sensitive with save since people learn "save often" to 
keep their data, well, safe. Calling something "save" which breaks 
happily data was totally unexpected to me when i started (in the 
times when even a "}" in a string meant trouble, much bette rnow)
james_nak
14-Sep-2006
[5329]
It's probably just me but what is the deal with command line arguments 
via system/script/args, I can't seem to get anything returned except 
none.
Anton
14-Sep-2006
[5330x2]
I wrote this a long time ago, but it should still be useful:
prin "args: "
probe any [
    system/options/args  ; this is available in user.r

    to-block system/script/args ; system/script/args is only available 
    after user.r, when script is done
]
james_nak
14-Sep-2006
[5332]
Anton, thanks. I get it. You have to "turn on" the feature then use 
system/script/args with a "do/args script.r"   Thanks.
Anton
15-Sep-2006
[5333]
Very good.
JaimeVargas
15-Sep-2006
[5334x3]
If rebol used unicode for source code the problem with deci! could 
be address in the same way that plt-scheme does. That is they just 
have exact and inexact numbers. Exact numbers print all digits up 
to the precision in a normal way. Inexact values print the number 
and the last digit has a dash on top. Operations of exact with inexact 
yield inexact. If the programer wants to warrant exactness he converst 
from inexact to exact, which just means removing a flag and assumming 
the number is exact to the number of digits given.
I know that due to efficient represeantion of values with 16bytes 
gives a constraint. But it would be really cool if rebol adopted 
the tower of numbers from Scheme.
Rebol offers a way for handling molding of new data types that could 
be exploited. We could mold an inexact deci! using something like 
#[deci! [precision: 4  value: 1.33333333]]