Skip to content

Commit 97fdfdb

Browse files
committed
Update Boost C++ snippet to include cast functions
1 parent 149b77d commit 97fdfdb

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

tools/snippets/test/fixtures/cpp/boost/runner.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,36 @@ void rand_array_i32( int *out, const unsigned int len, const int a, const int b
111111
}
112112
}
113113

114+
/**
115+
* Casts an array of integers to an array of doubles.
116+
*
117+
* @param out output array
118+
* @param x input array
119+
* @param len array length
120+
*/
121+
void i32_to_f64( double *out, int *x, unsigned int len ) {
122+
unsigned int i;
123+
124+
for ( i = 0; i < len; i++ ) {
125+
out[ i ] = (double) x[ i ];
126+
}
127+
}
128+
129+
/**
130+
* Casts an array of doubles to an array of integers.
131+
*
132+
* @param out output array
133+
* @param x input array
134+
* @param len array length
135+
*/
136+
void f64_to_i32( int *out, double *x, unsigned int len ) {
137+
unsigned int i;
138+
139+
for ( i = 0; i < len; i++ ) {
140+
out[ i ] = (int) x[ i ];
141+
}
142+
}
143+
114144
/**
115145
* Writes an array of doubles to a file as a series of comma-separated values.
116146
*

0 commit comments

Comments
 (0)