1988年,Intel386 SX微处理器中的晶体管数量为275,000个。在1997年,奔腾II英特尔微处理器的晶体管数是多少?
如果英特尔每两年将晶体管数量翻一番,新处理器将拥有
Pn = 275,000 * 2^n (where n = 9/2 = 4.5)
= 275,000 * 22.63
= 6.2 million transistors那么,如何使用C、C++或java实现此功能的代码呢?
发布于 2011-03-06 14:45:07
在C中:
#include <stdio.h>
#include <math.h>
#define BASELINE_CPU_YEAR 1988
#define BASELINE_CPU_TRANSISTORS 275000
/* Estimate transistor count for Intel CPUs for a given year
* based on Moore's law */
double moores_law(int year) {
float year_offset = (year - BASELINE_CPU_YEAR) / 2.0;
return BASELINE_CPU_TRANSISTORS * pow(2, year_offset);
}
int main () {
int year = 1997;
printf("Moore's law projects a %d CPU would have %.2f transistors.\n",
year, moores_law(year));
return 0;
}发布于 2011-03-06 17:15:01
确实如此。摩尔在1975年改变了他的预测,每两年将晶体管的数量增加一倍。
#include <stdio.h>
#include <math.h>
int main () {
double transistors = 275000;
double years = 1997-1988;
printf("%f", transistors*pow(2.0,years/2)); // 6222539.674442
getch();
return 0;
}发布于 2011-03-06 14:14:14
在java或c#中,您可以这样做
int year = 2010; //for example
double P0 = 275000;
float n = ((float)year - 1988) / 2; //1988 -> base year
double Pn = P0 * (Math.Pow(2, n));https://stackoverflow.com/questions/5209019
复制相似问题