我有一个与32位内存地址有关的非常基本的问题.我的理解是2 ^ 32是32位系统上可能的内存地址的最大数量.令我感到困惑的是我们如何从这个数字转到所谓的4GB限制.在我的研究中,我看到有些人这样做:
2 ^ 32 = 4,294,967,296字节
4,294,967,296 /(1,024*1,024)= ~4 GB
首先,这个(1,024*1,024)来自哪里?
其次,如果我错了,请纠正我,但是4,294,967,296被标记为字节,因为一个字节是可以在RAM中寻址的最小存储空间单位.由于我们仅限于2 ^ 32个地址,因此这是可以寻址的字节数.
第三,即使RAM中最小的可寻址空间是一个字节,硬盘也不一定如此,因为32位系统通常硬盘的容量超过4 GB.有人可以简要描述硬盘的寻址方案吗?
编译用C编写的OpenGL程序时,下面显示的初始命令会产生以下错误.
C:\Users\razz\Desktop>gcc -Wall -ofoo mycube.c -lglut32cu -lglu32 -lopengl32
C:\Users\razz\AppData\Local\Temp\ccs833b1.o:mycube.c:(.text+0x1c): undefined reference to `__glutInitWithExit'
C:\Users\razz\AppData\Local\Temp\ccs833b1.o:mycube.c:(.text+0x37): undefined reference to `__glutCreateWindowWithExit'
C:\Users\razz\AppData\Local\Temp\ccs833b1.o:mycube.c:(.text+0x52): undefined reference to `__glutCreateMenuWithExit'
C:\Users\razz\AppData\Local\Temp\ccs833b1.o:mycube.c:(.text+0x66): undefined reference to `_imp__glClear'
C:\Users\razz\AppData\Local\Temp\ccs833b1.o:mycube.c:(.text+0x6d): undefined reference to `_imp__glLoadIdentity'
C:\Users\razz\AppData\Local\Temp\ccs833b1.o:mycube.c:(.text+0x9e): undefined reference to `_imp__glRotatef'
C:\Users\razz\AppData\Local\Temp\ccs833b1.o:mycube.c:(.text+0xcf): undefined reference to `_imp__glRotatef'
C:\Users\razz\AppData\Local\Temp\ccs833b1.o:mycube.c:(.text+0xdd): undefined reference to `_imp__glBegin'
C:\Users\razz\AppData\Local\Temp\ccs833b1.o:mycube.c:(.text+0xfe): undefined reference to `_imp__glColor3f'
C:\Users\razz\AppData\Local\Temp\ccs833b1.o:mycube.c:(.text+0x11f): undefined reference to `_imp__glVertex3f'
C:\Users\razz\AppData\Local\Temp\ccs833b1.o:mycube.c:(.text+0x140): undefined reference to `_imp__glColor3f'
C:\Users\razz\AppData\Local\Temp\ccs833b1.o:mycube.c:(.text+0x161): undefined reference to `_imp__glVertex3f'
C:\Users\razz\AppData\Local\Temp\ccs833b1.o:mycube.c:(.text+0x182): undefined reference to `_imp__glColor3f'
C:\Users\razz\AppData\Local\Temp\ccs833b1.o:mycube.c:(.text+0x1a3): undefined reference to `_imp__glVertex3f'
C:\Users\razz\AppData\Local\Temp\ccs833b1.o:mycube.c:(.text+0x1c4): undefined …Run Code Online (Sandbox Code Playgroud) 下面我创建了一个包含 4 个 Person 类型元素的列表。我想根据 Age 属性按升序对 Person 列表进行排序。有没有一种优雅的方法可以使用 LINQ 或 IComparable(或其他东西)来实现这一点,这样我就不必从头开始编写自己的算法?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
List<Person> people = new List<Person>();
people.Add(new Person("Matthew", 27));
people.Add(new Person("Mark", 19));
people.Add(new Person("Luke", 30));
people.Add(new Person("John", 20));
// How to sort list by age?
}
private class Person
{
string Name { get; set; }
int Age { get; set; }
public Person(string name, int age)
{
Name = …Run Code Online (Sandbox Code Playgroud)