Sandbox: Difference between revisions

From Rosetta Code
Content added Content deleted
m (→‎XFeeds: Changed feeds)
No edit summary
Line 5: Line 5:


[[#Your Language Here]]
[[#Your Language Here]]


[[#Python]]
def avr24(data):
if len(data)==0:
return 0
else:
return sum(data)/float(len(data))


== XFeeds ==
== XFeeds ==
Line 17: Line 25:
#include <gmpxx.h>
#include <gmpxx.h>


mpf_class f(mpf_class x);
mpf_class f(mpf_class x);
double f(double x);
double f(double x);


int main()
int main()
{
{
unsigned int start = 1;
unsigned int start = 1;
unsigned int end = 1000;
unsigned int end = 1000;
mpf_class sum = 0;
mpf_class sum = 0;
double dsum = 0;
double dsum = 0;
for( unsigned int x = start;
for( unsigned int x = start;
x <= end;
x <= end;
++x )
++x )
{
{
sum += f(mpf_class(x));
sum += f(mpf_class(x));
dsum += f((double) x);
dsum += f((double) x);
}
}
std::cout << "Sum of f(x) from " << start << " to " << end << " is " << sum << " (GMP float) or " << dsum << " (IEEE 64-bit float)" << std::endl;
std::cout << "Sum of f(x) from " << start << " to " << end << " is " << sum << " (GMP float) or " << dsum << " (IEEE 64-bit float)" << std::endl;
return 0;
return 0;
}
}




mpf_class f(mpf_class x)
mpf_class f(mpf_class x)
{
{
return ( 1 / ( x * x ) );
return ( 1 / ( x * x ) );
}
}


double f(double x)
double f(double x)
{
{
return ( 1 / ( x * x ) );
return ( 1 / ( x * x ) );
}
}
</c>
</c>

Revision as of 18:03, 26 February 2008

blah

''blah''
''blah''


#Your Language Here


#Python def avr24(data):

   if len(data)==0:
       return 0
   else:
       return sum(data)/float(len(data))

XFeeds

<xfeeds contentcolour="#eeeeee" feedlimit="3" totallimit="10"> http://blog.rosettacode.org/?feed=rss2 http://blog.rosettacode.org/?feed=comments-rss2 </xfeeds>

Syntax highlighting

<c>#include <iostream>

  1. include <gmpxx.h>

mpf_class f(mpf_class x); double f(double x);

int main() {

unsigned int start = 1;
unsigned int end = 1000;
mpf_class sum = 0;
double dsum = 0;

for( unsigned int x = start;
  x <= end;
  ++x   )
{
 sum += f(mpf_class(x));
 dsum += f((double) x);
}

std::cout << "Sum of f(x) from " << start << " to " << end << " is " << sum << " (GMP float) or " << dsum << " (IEEE 64-bit float)" <<  std::endl;
return 0;

}


mpf_class f(mpf_class x) {

return ( 1 / ( x * x ) );

}

double f(double x) {

return ( 1 / ( x * x ) );

} </c>

Expression test

Currently there are 2,649 articles, but if someone added another, there would be 2650 articles. Totally, there are 20,468 pages, which means that 17819 pages are not articles.

Your Language Here

Works with: Yourlanguagehere

Testing a standard language solution header.

Works with: Yourlanguagehere version 2.5
Works with: Display name version 2.5

Your Language Here

Testing a standard language solution header with different display name.



Animated FIFO

colorForth

source
colorForth
code

26 →

170 ¬

224-234 αßΓπΣσµτΦΘΩ

236 ∞

241-243 ±≥≤


244 ⌠

245 ⌡


246 ÷

247 ≈

248 °

251 √

253 ²

<sub> normalsub

<sup> normalsup

Template:WP

Template:WP