loss of data

I have a project due in a couple of days an i need help with a couple of lines. my professor says that it is best to use data type int instead of doubles for log10. I get a compiler error that reads:
"'log10' : ambiguous call to overloaded function"
how can i get through this? and i also get another error that reads:
"'=' : conversion from 'double' to 'int', possible loss of data please help. the peice of code that has erros is below. thank you.

int R_Min, R_Max, R_Ave, Tol; // Tol = tolerance percentage ( D )
int A, B, C, D;
cout << "Enter Minimum Resistance Value: " << endl;
cin >> R_Min;
cout << "Enter Maximum Resistance Value: " << endl;
cin >> R_Max;
R_Ave = ((.5)*(R_Min+R_Max))/ R_Max;
cout << "The Mean (Average) Resistance Value is " << R_Ave << endl;
Tol= (100*(R_Max-R_Ave))/R_Ave;
D = Tol ;
C = log10 (R_Ave);
A = R_Ave / pow(10.0, C);
B = R_Ave / pow(10.0, C-1);
B = B- (A*10);
Please post your entire code, and put it in code tags: the <> symbol in format.
The first message means that there is no overload function log10 that has the parameter of type int. Usually the compiler also lists candidate functions in additional error messages. You should cast the argument to one of float number types.
The second message says that during converting result value of an expression of type double to type int it is possible loss of data.

The messages are very clear so I wonder why did you ask your question? Read messages of the compiler!
Last edited on
yeah i didn't cathch the "warning"
i have less than a semester working on this so i'm fairly new at this and still learning the basics.
i am using a header that my professor made so i can view the image printed.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#include <iostream>

#include "csufmedia.h"
#include <math.h>

using namespace std;

int main() 
{
	int R_Min, R_Max, R_Ave, Tol; // Tol = tolerance percentage ( D )
	int A, B, C, D;
	cout << "Enter Minimum Resistance Value: " << endl;
	cin >> R_Min;
	cout << "Enter Maximum Resistance Value: " << endl;
	cin >> R_Max;
R_Ave = ((.5)*(R_Min+R_Max))/ R_Max;
cout << "The Mean (Average) Resistance Value is " << R_Ave << endl;
Tol= (100*(R_Max-R_Ave))/R_Ave;
D = Tol ;
C = log10 (R_Ave);
A = R_Ave / pow(10.0, C);
B = R_Ave / pow(10.0, C-1);
B = B- (A*10);
cout << "A: " << A << endl;
cout << "B: " << B << endl;
cout << "C: " << C << endl;
cout << "D: " << D << endl;

make_canvas(1,200);

A>=0 && A<=9 , B>=0 && B<=9 , C>=0 && C<=9;
switch (A)
{
	if (A>=0)
case 0:
	add_column(20,0,0,0); // black
	add_column(20,.96,.96,.96); // beige
	break;
case 1:
	add_column(20,.65,.16,.16); // brown
	add_column(20,.96,.96,.96); // beige
	break;
case 2:
	add_column(20,1,0,0); // red
	add_column(20,.96,.96,.96); // beige
	break;
case 3:
	add_column(20,1,.65,0); // orange
	add_column(20,.96,.96,.96); // beige
	break;
case 4:
	add_column(20,1,1,0); // yellow
	add_column(20,.96,.96,.96); // beige
	break;
case 5:
	add_column(20,0,1,0); // green
	add_column(20,.96,.96,.96); // beige
	break;
case 6:
	add_column(20,0,0,1); // blue
	add_column(20,.96,.96,.96); // beige
	break;
case 7:
	add_column(20,.93,.51,.93); // violet
	add_column(20,.96,.96,.96); // beige
	break;
case 8:
	add_column(20,.50,.50,.50); // gray
	add_column(20,.96,.96,.96); // beige
	break;
case 9:
	add_column(20,1,1,1); // white
	add_column(20,.96,.96,.96); // beige
	break;
}
switch (B)
{
	if (B>=0)
case 0:
	add_column(20,0,0,0); // black
	add_column(20,.96,.96,.96); // beige
	break;
case 1:
	add_column(20,.65,.16,.16); // brown
	add_column(20,.96,.96,.96); // beige
	break;
case 2:
	add_column(20,1,0,0); // red
	add_column(20,.96,.96,.96); // beige
	break;
case 3:
	add_column(20,1,.65,0); // orange
	add_column(20,.96,.96,.96); // beige
	break;
case 4:
	add_column(20,1,1,0); // yellow
	add_column(20,.96,.96,.96); // beige
	break;
case 5: 
	add_column(20,0,1,0); // green
	add_column(20,.96,.96,.96); // beige
	break;
case 6:
	add_column(20,0,0,1); // blue
	add_column(20,.96,.96,.96); // beige
	break;
case 7:
	add_column(20,.93,.51,.93); // violet
	add_column(20,.96,.96,.96); // beige
	break;
case 8:
	add_column(20,.50,.50,.50); // gray
	add_column(20,.96,.96,.96); // beige
	break;
case 9:
	add_column(20,1,1,1); // white
	add_column(20,.96,.96,.96); // beige
	break;
}
switch (C)
{
	if (C>=0)
case 0:
	add_column(20,0,0,0); // black
	add_column(40,.96,.96,.96); // beige
	break;
case 1:
	add_column(20,.65,.16,.16); // brown
	add_column(40,.96,.96,.96); // beige
	break;
case 2:
	add_column(20,1,0,0); // red
	add_column(40,.96,.96,.96); // beige
	break;
case 3:
	add_column(20,1,.65,0); // orange
	add_column(40,.96,.96,.96); // beige
	break;
case 4:
	add_column(20,1,1,0); // yellow
	add_column(40,.96,.96,.96); // beige
	break;
case 5:
	add_column(20,0,1,0); // green
	add_column(40,.96,.96,.96); // beige
	break;
case 6:
	add_column(20,0,0,1); // blue
	add_column(40,.96,.96,.96); // beige
	break;
case 7:
	add_column(20,.93,.51,.93); // violet
	add_column(40,.96,.96,.96); // beige
	break;
case 8:
	add_column(20,.50,.50,.50); // gray
	add_column(40,.96,.96,.96); // beige
case 9:
	add_column(20,1,1,1); // white
	add_column(40,.96,.96,.96); // beige
	break;
}
if ((D >= 0) && (D <= 5))
{
	add_column(20,1,.83,0); // gold
	add_column(20,.96,.96,.96); // beige
}
else if ((D > 5) && (D <= 10))
{
	add_column(20,.75,.75,.75); // silver
	add_column(20,.96,.96,.96); // beige
}
else
{
	add_column(40,.96,.96,.96);
}
save_canvas("resistor.ppm");
return 0;
}

Topic archived. No new replies allowed.