c++ - Convert radians to degrees like Google -


im trying convert radians degrees, im not getting same results google

calculator , pi defined dosent output number.

if type in google search: (1 * 180) / 3.14159265 57.2957796, program

outputting: 57.2958 , if type in google search pi get: 3.14159265, mine

dosent output rest, output: 3.14159

my code is:

#include <iostream> #define show(x) cout << # x " = " << (x) << endl  using namespace std;  double pi_test = 3.14159265;  float radian_to_degree(double  enter) {   double pi = 3.14159265;   float degrees = (enter * 180) / pi;   return degrees; }  int main (int argc, char * const argv[]) {     show( radian_to_degree(1) ); // 57.2958 not 57.2957795 google, why?     show( pi_test ); // output 3.14159' not 3.14159265, why?      return 0; } 

please me fix this, wrong? example?

as stated here, may cout in c++ rounding number before displaying it. try this:

#define show(x) cout << setprecision(some_number) << # x " = " << (x) << endl 

Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -