Guest User

Untitled

a guest
Jun 18th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. for (i=0 ;i< len; i++)
  2. float_buff[i]= (float) char_buff[i];
  3.  
  4. for (i=0 ;i< len; i++)
  5. char_buff[i]= (unsigned char) float_buff[i];
  6.  
  7. char_buff[i]= static_cast<unsigned char>(float_buff[i]);
  8.  
  9. template <typename T> // T models Any
  10. struct static_cast_func
  11. {
  12. template <typename T1> // T1 models type statically convertible to T
  13. T operator()(const T1& x) const { return static_cast<T>(x); }
  14. };
  15.  
  16. std::transform(char_buff, char_buff + len, float_buff, static_cast_func<float>());
  17. std::transform(float_buff, float_buff + len, char_buff, static_cast_func<unsigned char>());
  18.  
  19. for (i=0; i< len; i++)
  20. char_buff[i]= static_cast<unsigned char>(float_buff[i]);
  21.  
  22. std::copy(char_buff,char_buff+len,float_buff);
  23.  
  24. std::transform(float_buff,float_buff+len,char_buff,MyTransform());
  25.  
  26. float *dst = float_buff;
  27. unsigned char *src = char_buff;
  28.  
  29. for (i=0; i<len; i++) *dst++ = (float)*src++;
Add Comment
Please, Sign In to add comment