Return type word

Hello,

Is it possible to return type word from a function? If not what could be used as a replacement?

Here is a look at my example code:

 word PowerSupply::monitor(double expectedVolt, float inVal)
    {
        int i = 0 ; 
        double positive[162] = 
            {
              478,499,517,534,551,567,583,599,615,630,646,661,676,692,707,722,
              737,752,767,782,798,813,828,843,857,872,887,902,917,932,947,962,
              977,992,1006,1021,1036,1051,1066,1080,1095,1110,1125,1140,1154,
              1169,1184,1199,1213,1228,1243,1258,1272,1287,1302,1317,1331,1346,
              1361,1375,1390,1405,1419,1434,1449,1464,1478,1493,1508,1522,1537,
              1552,1566,1581,1596,1610,1625,1640,1654,1669,1684,1698,1713,1727,
              1742,1757,1771,1786,1801,1815,1830,1845,1859,1874,1889,1903,1918,
              1932,1947,1962,1976,1991,2006,2020,2035,2049,2064,2079,2093,2108,
              2122,2137,2152,2166,2181,2196,2210,2225,2239,2254,2269,2283,2298,
              2312,2327,2342,2356,2371,2385,2400,2415,2429,2444,2458,2473,2488,
              2502,2517,2531,2546,2561,2575,2590,2604,2619,2634,2648,2663,2677,
              2692,2707,2721,2736,2750,2765,2779,2794,2809,2823,2838
            };
                word outVal ; 
                         i = expectedVolt* 10 ; //Round to near Val
                 outVal = positive[i];
                 return outVal;    
        }

Thanks in advance

Have you got a definition for "word"? It isn't a native type.

Yes, its a 16 bit value. Similar to type byte which is 8 bits. I was using this type because with my project I'm using an external SPI dac (MCP4921) which requires a 16 bit word to write to the dac.

Using this type makes it easier to separate the high byte from the low, but if there is an alternative I would be happy to switch.

Thanks again

Unsigned int?

double positive[162] = 
			{
			  478,499,517,534,551,567,583,599,615,630,646,661,676,692,707,722,
			  737,752,767,782,798,813,828,843,857,872,887,902,917,932,947,962,
			  977,992,1006,1021,1036,1051,1066,1080,1095,1110,1125,1140,1154,
			  1169,1184,1199,1213,1228,1243,1258,1272,1287,1302,1317,1331,1346,
			  1361,1375,1390,1405,1419,1434,1449,1464,1478,1493,1508,1522,1537,
			  1552,1566,1581,1596,1610,1625,1640,1654,1669,1684,1698,1713,1727,
			  1742,1757,1771,1786,1801,1815,1830,1845,1859,1874,1889,1903,1918,
			  1932,1947,1962,1976,1991,2006,2020,2035,2049,2064,2079,2093,2108,
			  2122,2137,2152,2166,2181,2196,2210,2225,2239,2254,2269,2283,2298,
			  2312,2327,2342,2356,2371,2385,2400,2415,2429,2444,2458,2473,2488,
			  2502,2517,2531,2546,2561,2575,2590,2604,2619,2634,2648,2663,2677,
			  2692,2707,2721,2736,2750,2765,2779,2794,2809,2823,2838
			};

A double array full of ints. Why?

According to this: http://arduino.cc/en/Reference/Word

word is a type defined by the IDE.

Sounds like a bug or bad docs.

I just switched the values in the table from decimals, it should also be a type that is 16 bits.
That really has no relevance though. Thanks for pointing it out
so I can change it.

I tried using unsigned int and it worked!
http://arduino.cc/en/Reference/Word : also says its the same as unsigned int!

Thanks for all your help

 i = expectedVolt* 10 ; //Round to near Val
 outVal = positive[i];

I would be doing some bounds checking if I were you. What if expectedVolt is >= 16.2?