issue-#124 Range-check for SHORT(ENTIER(real))
Re: issue-#124 Range-check for SHORT(ENTIER(real))
Still not happy about MOD.
1 - The same thing (about from the very obvious difference) occurs for both INTEGER & LONGINT, so it is less confusing to describe it using the same wording.
2 - INTEGER. "The low bits of the correct answer are returned". This is confusing; all the correct answer is returned (I think!).
3 - LONGINT. "MOD is range checked, and overflows ...". Again confusing; it does not need range checking, and overflows cannot occur.
1 - The same thing (about from the very obvious difference) occurs for both INTEGER & LONGINT, so it is less confusing to describe it using the same wording.
2 - INTEGER. "The low bits of the correct answer are returned". This is confusing; all the correct answer is returned (I think!).
3 - LONGINT. "MOD is range checked, and overflows ...". Again confusing; it does not need range checking, and overflows cannot occur.
- Josef Templ
- Posts: 2047
- Joined: Tue Sep 17, 2013 6:50 am
Re: issue-#124 Range-check for SHORT(ENTIER(real))
MOD can indeed be removed from that section. It never produces an out-of-range value.
> 2 - INTEGER. "The low bits of the correct answer are returned". This is confusing; all the correct answer is returned (I think!).
MAX(INTEGER) * MAX(INTEGER), e.g., produces a value larger than INTEGER
but not the full answer is returned. This was correct.
For the diff see http://redmine.blackboxframework.org/pr ... 0988269fc4.
I also replaced 'correct answer' by 'result'. Sounds less negative to me.
- Josef
> 2 - INTEGER. "The low bits of the correct answer are returned". This is confusing; all the correct answer is returned (I think!).
MAX(INTEGER) * MAX(INTEGER), e.g., produces a value larger than INTEGER
but not the full answer is returned. This was correct.
For the diff see http://redmine.blackboxframework.org/pr ... 0988269fc4.
I also replaced 'correct answer' by 'result'. Sounds less negative to me.
- Josef
Re: issue-#124 Range-check for SHORT(ENTIER(real))
Misunderstandings are so easy! I meant it was confusing in the context of MOD. Of course it is correct for the other procedures.Josef Templ wrote:MAX(INTEGER) * MAX(INTEGER), e.g., produces a value larger than INTEGER
but not the full answer is returned. This was correct.
Anyway, I am happy with the current text.
Re: issue-#124 Range-check for SHORT(ENTIER(real))
A college has just run my example in Microsoft Visual Studio 2010 C. BlackBox is significantly different and (in my opinion) much better.Josef Templ wrote:As far as I know this (ie real arithmetic rounding) is very much the same as in C.
Notes:
1 - C & C# behave the same as each other.
2 - Both C & C# behave differently depending if the target application is a 32 or 64 bit application. Who would have guessed that?
- Attachments
-
- Floats2.pdf
- BlackBox vs C arithmetic precision
- (40.7 KiB) Downloaded 3661 times
Re: issue-#124 Range-check for SHORT(ENTIER(real))
the BB's result can be produced easily by a c compilerRobert wrote: A college has just run my example in Microsoft Visual Studio 2010 C. BlackBox is significantly different and (in my opinion) much better.
Code: Select all
#include <stdio.h>
// #include <math.h>
int main(int argc, char** argv){
float a, b, c, s, t, u, x, y;
__asm
{
push 830 ;33EH
fldcw [esp]
pop ecx
}
/* //gcc
asm("pushl $830");
asm("fldcw (%esp)");
asm("popl %ecx");
*/
a = 10000000.;
b = 3.0;
c = 3333333.0;
x = a * (a / b - c) - c; //(* Correct to 5 / 5 digits *)
printf("%.16f\n", x);
s = a / b;
t = s - c;
u = a * t;
y = u - c; // (* Correct to 2 / -6 digits *)
printf("%.16f\n", y); //(* Correct to 7 digits *)
return 0;
}
will confuse normal users. so most compiler select float64 as default(internal) precision.
c & c# compiler, are industry products,heavily optmized and updated for modern cpu,
BB compiler cant compete with them in many aspects.
luowy
Re: issue-#124 Range-check for SHORT(ENTIER(real))
I assumed that you were talking about "Default" compiler settings. I am not surprised that you can use Assembler to change things, you can do that in BlackBox also - and I do!. There are probably (Microsoft, gcc, ?) compiler options that enable changed behaviour even without using Assembler.luowy wrote:What result does the C compiler give us? I prefer C standard.
My points are:
- The phrase "C standard" does not allow us (me ?) to easily and unambiguously know precisely what you mean
- and we may not want to do the same anyway.
Your final result shows that the gcc optimiser is making significant rearrangements to the code, which (here) makes it much more accurate, and probably significantly faster.
Do we want such optimisation in BlackBox? - I think there is no point thinking about the answer because we can't afford to implement it even if we did.
Your comment: "confuse normal users" - I couldn't agree more!
-
- Posts: 204
- Joined: Wed Sep 18, 2013 10:06 pm
- Contact:
Re: issue-#124 Range-check for SHORT(ENTIER(real))
Is there a reason why you have written the example in this way? I would have written it as:Robert wrote: A college has just run my example in Microsoft Visual Studio 2010 C. BlackBox is significantly different and (in my opinion) much better.
Code: Select all
a := 10.0;
b := 3.0;
c := 3.0;
x := a * (a / b - c) - c;
...
...
x: 0.33333333333333481
y: 0.33333333333333481
This was using GPCP for .NET but I would expect identical results for C# as your example gave identical results for GPCP and C#.
Re: issue-#124 Range-check for SHORT(ENTIER(real))
Firstly there is a typo in the bottom line of my .pdf: for "C(#)32" read "C(#)64".
I'm sorry, but I don't really understand your post, in particular the two "identicals" in the last line.
Are you comparing:
- Your example with mine
- GPCP with BlackBox
- REALs with SHORTREALs
- In-line with non in-line source code
- WIN32.exe with WIN64.exe?
Maybe it would be clearer to me if you gave a table of your actual results.
Cheers
That is a different question, and leads to a different answer. No surprise there. I chose my particular example as it emphasises the differences, but I could have chosen many other examples.cfbsoftware wrote:Is there a reason why you have written the example in this way? I would have written it as:
I'm sorry, but I don't really understand your post, in particular the two "identicals" in the last line.
Are you comparing:
- Your example with mine
- GPCP with BlackBox
- REALs with SHORTREALs
- In-line with non in-line source code
- WIN32.exe with WIN64.exe?
Maybe it would be clearer to me if you gave a table of your actual results.
Cheers
- Josef Templ
- Posts: 2047
- Joined: Tue Sep 17, 2013 6:50 am
Re: issue-#124 Range-check for SHORT(ENTIER(real))
I have recreated the topic branch for issue-#100 because it had such a long list of minor updates.
Now it is in one commit.
For me this is ready for voting.
- Josef
Now it is in one commit.
For me this is ready for voting.
- Josef
-
- Posts: 204
- Joined: Wed Sep 18, 2013 10:06 pm
- Contact:
Re: issue-#124 Range-check for SHORT(ENTIER(real))
Just ignore what I said. I now understand that I misunderstood your postRobert wrote:I'm sorry, but I don't really understand your post