I'm new to Solidity and I'm having some troubles with type issues. I'm trying to execute the following functions:
function sigmoidSingle(int128 x) public pure returns(int128)
{
//The sigmoid function is f(x) = 1 / (1 + e^(-x))
x = ONE + ABDKMath64x64.exp(-x);
int128 y = ABDKMath64x64.div(ONE,x);
return y;
}
//Sigmoid activation function to process a np array
function sigmoid(int128[] memory x) public pure returns(int128[] memory)
{
uint xSize = x.length;
int128[] memory y_Preds = new int128[](xSize);
for(uint8 i = 0; i < xSize; i++ )
{
y_Preds[i] = sigmoidSingle(x[i]);
}
return y_Preds;
}
where the input array x of the sigmoid function is an array of 64.64 fixed point format numbers. I am converting the numbers with Python taking advantage of the following function:
def toFixedPoint64(x):
x = x * (2**64)
y = round(x + 0.5)
return y
Now, assume that i want to convert the following array of floating point numbers:
[0.52,0.49,-0.20,0.57]
The resulting array would be:
[9592306918328967168, 9038904596117680128, -3689348814741910528, 10514644122014443520]
When i give in input this array to sigmoid function, i'm getting the following error:
Error encoding arguments: Error: invalid number value (arg="", coderType="int128", value=9592306918328967000, version=4.0.44)
I don't get why I am having this issue, indeed with an int128 i should be able to represent higher values of this one. Also i don't get why the number is cut to 9592306918328967000. Consider that if I give in input the number 9592306918328967168 to the sigmoidSingle function i don't get any problem, on the contrary it returns the correct result. Now, I suspect that the problem may arise because of the array, but since I'm not a Solidity expert I don't know what to think. Is there anyone who can help me understand the situation?
UPDATE: It is a problem of the VM simulator. Giving the number surrounded by quotation marks should work. Ex: "9592306918328967168" is the correct way to give in input this int128 to Remix GUI.