In the past I have tried to replicate this behavior in Vajolet but i got huge elo loss.
Today I tried to understand why and I write a program that verify the correctness of adding positive/ negative value using the compact way.
I have seen that the resulting value are wrong in the high half by +-1. Is this known and accepted because the score is then scaled, or am I doing something wrong?
this is my code
Code: Select all
#include <iostream>
#include <stdlib.h>
using namespace std;
union comp{
short int si[2];
unsigned int i;
}compostoRes,composto1,composto2;
int main() {
cout << "start" << endl; // prints
int maxErr=0;
short int start=-1,stop=0;
for(short int a=start;a<stop;a++){
for(short int b=start;b<stop;b++){
//std::cout<<a<<":"<<b<<" "<<maxErr<<std::endl;
for(short int c=start;c<stop;c++){
for(short int d=start;d<stop;d++){
int sum1=a+b;
int sum2=c+d;
composto1.si[0]=a;
composto1.si[1]=c;
composto2.si[0]=b;
composto2.si[1]=d;
compostoRes.i=composto1.i+composto2.i;
if(abs(compostoRes.si[0]-sum1)>maxErr){
maxErr=abs(compostoRes.si[0]-sum1);
}
if(abs(compostoRes.si[1]-sum2)>maxErr){
maxErr=abs(compostoRes.si[1]-sum2);
}
if(compostoRes.si[0]!=sum1 || compostoRes.si[1]!=sum2){
std::cout<<"a:"<<a<<",b:"<<b<<",c:"<<c<<",d:"<<d<<std::endl;
std::cout<<"res:"<<compostoRes.si[0]<<","<<compostoRes.si[1]<<std::endl;
std::cout<<"sum:"<<sum1<<","<<sum2<<std::endl;
std::cout<<"composto1:"<<composto1.i<<std::endl;
std::cout<<"composto2:"<<composto2.i<<std::endl;
}
std::cout<<"res:\t"<<compostoRes.i<<std::endl;
compostoRes.si[0]=sum1;
compostoRes.si[1]=sum2;
std::cout<<"wanted:\t"<<compostoRes.i<<std::endl;
/*else{
std::cout<<"good"<<std::endl;
}*/
}
}
}
}
std::cout<<"Max err: "<<maxErr<<std::endl;
cout << "end" << endl; // prints
and this is the result I got:
Code: Select all
a:-1,b:-1,c:-1,d:-1
res:-2,-1
sum:-2,-2
composto1:4294967295
composto2:4294967295
res: 4294967294
wanted: 4294901758
Max err: 1
end

