Permalink
Browse files

Added UKRandomInteger: Simple wrapper around rand() that generates an…

… NSInteger of the appropriate size for the current architecture.
  • Loading branch information...
1 parent ffb8554 commit 3a22fe65363d19309eae41dd79cca1b601bd42d4 @uliwitness committed Apr 25, 2010
Showing with 33 additions and 0 deletions.
  1. +14 −0 UKRandomInteger.h
  2. +19 −0 UKRandomInteger.m
View
14 UKRandomInteger.h
@@ -0,0 +1,14 @@
+//
+// UKRandomInteger.h
+// Propaganda
+//
+// Created by Uli Kusterer on 25.04.10.
+// Copyright 2010 The Void Software. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+
+NSInteger UKRandomInteger();
+
+
View
19 UKRandomInteger.m
@@ -0,0 +1,19 @@
+//
+// UKRandomInteger.m
+// Propaganda
+//
+// Created by Uli Kusterer on 25.04.10.
+// Copyright 2010 The Void Software. All rights reserved.
+//
+
+#import "UKRandomInteger.h"
+
+
+NSInteger UKRandomInteger()
+{
+ #if __LP64__
+ return (((NSInteger)rand()) | ((NSInteger)rand()) << 32);
+ #else
+ return rand();
+ #endif
+}

0 comments on commit 3a22fe6

Please sign in to comment.