onilink_

variadics

May 29th, 2020
749
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1.  
  2. namespace gml
  3. {
  4.  
  5. double min(StackParams params)
  6. {
  7.     double out = std::numeric_limits<double>::max();
  8.     for(unsigned i=0; i<params.argc; ++i)
  9.     {
  10.         auto t = DataType(params.ds->pop_value<uint8_t>());
  11.         assert(t == DataType::f64);
  12.         double x = params.ds->pop_value<double>();
  13.         if(x < out) {
  14.             out = x;
  15.         }
  16.     }
  17.     return out;
  18. }
  19.  
  20. double max(StackParams params)
  21. {
  22.     double out = std::numeric_limits<double>::min();
  23.     for(unsigned i=0; i<params.argc; ++i)
  24.     {
  25.         auto t = DataType(params.ds->pop_value<uint8_t>());
  26.         assert(t == DataType::f64);
  27.         double x = params.ds->pop_value<double>();
  28.         if(x > out) {
  29.             out = x;
  30.         }
  31.     }
  32.     return out;
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment