-3
for(int i = 0; i < iData; i++)
{
    if(hPred[i]<=jData[i])
    {
        akur[i] = hPred[i] / jData[i];
    }
    else if(hPred[i]>jData[i])
    {
        akur[i] = hPred[i] / jData[i];
        akur[i] = akur[i] - 1.000;
    }
}

I got some issues here. I wanted to divide data in hPred[] with jData[] and store it in an array as double(akur[]). Instead, I got this:

jData[]

hPred[] and the result(akur[])

RESULT

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
  • So what exactly is the problem? What's the expected output? – Mureinik Oct 14 '21 at 09:30
  • Why we need "else if" case here? What is the data type for your array? And please provide textual output as text and not as an image on any external servers. Links may be gone in the future... – Klaus Oct 14 '21 at 09:30
  • I want to count the accuracy of data (it's a prediction) – Luthfi Hakim Oct 14 '21 at 09:33
  • Can you please stop adding pictures here! – Klaus Oct 14 '21 at 09:35
  • 1
    As long as we do not know the numbers in hPred and jData we can't know the result of a division?! Maybe you give us a complete sample of your function/method! inlcuding some sample data. – MiniMik Oct 14 '21 at 09:35
  • typecast any operand to float while division, eg : akur[i] = (float)hPred[i] / jData[i]; – thomachan Oct 14 '21 at 09:36
  • Your problem is you first do integer division and then cast the result to double. That's not going to add any decimal values to the result. You should expand the question to include all the variables' declarations. – Jorge Bellon Oct 14 '21 at 09:41
  • Sorry, I can't respond as quickly as possible. I'm studying in a boarding school, which restricts its students from using pc/electronic devices. I can only respond in an uncertain time. But now, I just resolved the problems, Thanks :) – Luthfi Hakim Oct 15 '21 at 13:27

1 Answers1

-2
for(int i = 0; i < iData; i++){
    if(hPred[i]<=jData[i]){
        akur[i] = (float)hPred[i] / jData[i];
    }else if(hPred[i]>jData[i]){
        akur[i] = (float)hPred[i] / jData[i];
        akur[i] = akur[i] - 1.000;
    }
}

typecast any operand to float before division

thomachan
  • 378
  • 3
  • 14