project_files/hwc/rtl/system.c
changeset 10625 125e120165aa
parent 10134 81d733899e06
child 10838 2abe883c9c21
--- a/project_files/hwc/rtl/system.c	Thu Dec 04 11:19:38 2014 -0500
+++ b/project_files/hwc/rtl/system.c	Thu Dec 04 20:15:03 2014 +0100
@@ -296,6 +296,11 @@
 }
 
 LongInt fpcrtl_random(LongInt l) {
+    // random(0) is undefined in docs but effectively returns 0 in free pascal
+    if (l == 0) {
+        printf("WARNING: random(0) called!");
+        return 0;
+    }
     return (LongInt) (rand() / (double) RAND_MAX * l);
 }