Time for an 2014 update…

This commit is contained in:
Ingy döt Net 2014-01-17 05:32:22 +00:00
parent 372c577f83
commit 09687c4926
2520 changed files with 34227 additions and 7318 deletions

View file

@ -0,0 +1,32 @@
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.sampler.getSize;
public class VariableSizeGet extends Sprite {
public function VariableSizeGet() {
if ( stage ) _init();
else addEventListener(Event.ADDED_TO_STAGE, _init);
}
private function _init(e:Event = null):void {
var i:int = 1;
var n:Number = 0.5;
var s:String = "abc";
var b:Boolean = true;
var date:Date = new Date();
trace("An int contains " + getSize(i) + " bytes."); // 4
trace("A Number contains " + getSize(n) + " bytes."); // 8
trace("The string 'abc' contains " + getSize(s) + " bytes."); // 24
trace("A Boolean contains " + getSize(b) + " bytes."); // 4
trace("A Date object contains " + getSize(date) + " bytes."); // 48
}
}
}

View file

@ -0,0 +1,25 @@
package main
import (
"fmt"
"reflect"
"runtime"
"unsafe"
)
func main() {
// unsafe.Sizeof returns the size in bytes.
var i int
fmt.Println(unsafe.Sizeof(i))
// The size returned is that of the top level object and does not
// include any referenced data. A type like string always returns
// the same number, the size of the string header.
fmt.Println(unsafe.Sizeof("Rosetta"))
fmt.Println(unsafe.Sizeof("Code"))
// For some untrusted environments, package unsafe is not available
// but reflect is. The Size method of a type will return the same value
// as unsafe.Sizeof.
fmt.Println(reflect.TypeOf("Cod").Size())
// Some sizes are implementation dependent.
fmt.Println(runtime.Version(), runtime.GOARCH)
}

View file

@ -5,4 +5,4 @@ julia> t = 1
1
julia> sizeof(t)
4
8