int main() { float a[32]; float b[32]; float start; float s; int i; start = -11.; s = -50.; for (i=4; i < 32; i++){ b[i] = start; start = start + 3.; } #pragma omp simd reduction(+: s) for (i=4; i < 32; i++) { a[i] = 2. * b[i]; s = s + a[i]; } printfloat(s); for (i = 4; i < 32; i++){ printfloat(a[i]); } return 0; }
void defconst(int ty, uValue_t v) { switch (ty) { case C: print("\tDB(%d)\n", v.uc); break; case S: print("\tDB(%d)\n", v.us); break; case I: print("\tDW(%d)\n", v.i ); break; case U: print("\tDW($%x)\n", v.u ); break; case P: print("\tDW($%x)\n", v.p ); break; case F: //__asm { int 3 }; printfloat(v.f); break; case D: //__asm { int 3 }; printfloat(v.d); break; default: assert(0); } }
void runtime·printcomplex(Complex128 v) { runtime·write(2, "(", 1); runtime·printfloat(v.real); runtime·printfloat(v.imag); runtime·write(2, "i)", 2); }
void printVar(char *name, float var) { DEBUG_PRINT(name); DEBUG_PRINT(": "); if((var - (int) var) == 0){ DEBUG_PRINT("(int) "); DEBUG_PRINTLN(var); } else{ DEBUG_PRINT("(float) "); printfloat(var); } }
int main(){ init(); disp_init(); printint(0, 50, 0); disp_home(); while(1) { printfloat(touch_wait(), 50, 0); disp_home(); } return 0; }
int main(int argc, char *argv[]) { char c = -1; short s = -1; int i = -1; long l = -1; float f = -1.0f; double d = -1.0; long double q = -1.0; double md = 1.0e16; double md2; double d201 = 2.01; for(double db = 0; db < 100; db++) { double d = db / 100 * 100; printf("%.16f = %.16f %.16f\n", db, d, fabs(db-d)); } if (md == md+1) { md2 = md+1; printf("%.16f(1.0e16)가 %.16f + 1와 같다\n", md, md); dump_binary(&md, sizeof(md)); dump_binary(&md2, sizeof(md2)); } printf("d201 = %.2f => (int)(d201*100) = %d\n", d201, (int)(d201 * 100)); dump_binary(&c, sizeof(c)); dump_binary(&s, sizeof(s)); dump_binary(&i, sizeof(i)); dump_binary(&l, sizeof(l)); dump_binary(&f, sizeof(f)); dump_binary(&d, sizeof(d)); dump_binary(&q, sizeof(q)); printf("%2d ==> [%s] \n", sizeof(c), to_binary(&c, sizeof(c))); printf("%2d ==> [%s] \n", sizeof(s), to_binary(&s, sizeof(s))); printf("%2d ==> [%s] \n", sizeof(i), to_binary(&i, sizeof(i))); printf("%2d ==> [%s] \n", sizeof(l), to_binary(&l, sizeof(l))); printf("%2d ==> [%s] \n", sizeof(f), to_binary(&f, sizeof(f))); printf("%2d ==> [%s] \n", sizeof(d), to_binary(&d, sizeof(d))); printf("%2d ==> [%s] \n", sizeof(q), to_binary(&q, sizeof(q))); printfloat(f); }
// Very simple printf. Only for debugging prints. // Do not add to this without checking with Rob. static void vprintf(int8 *s, byte *base) { int8 *p, *lp; uintptr arg, narg; byte *v; // lock(&debuglock); lp = p = s; arg = 0; for(; *p; p++) { if(*p != '%') continue; if(p > lp) runtime·write(2, lp, p-lp); p++; narg = 0; switch(*p) { case 't': narg = arg + 1; break; case 'd': // 32-bit case 'x': arg = runtime·rnd(arg, 4); narg = arg + 4; break; case 'D': // 64-bit case 'U': case 'X': case 'f': arg = runtime·rnd(arg, sizeof(uintptr)); narg = arg + 8; break; case 'C': arg = runtime·rnd(arg, sizeof(uintptr)); narg = arg + 16; break; case 'p': // pointer-sized case 's': arg = runtime·rnd(arg, sizeof(uintptr)); narg = arg + sizeof(uintptr); break; case 'S': // pointer-aligned but bigger arg = runtime·rnd(arg, sizeof(uintptr)); narg = arg + sizeof(String); break; case 'a': // pointer-aligned but bigger arg = runtime·rnd(arg, sizeof(uintptr)); narg = arg + sizeof(Slice); break; case 'i': // pointer-aligned but bigger case 'e': arg = runtime·rnd(arg, sizeof(uintptr)); narg = arg + sizeof(Eface); break; } v = base+arg; switch(*p) { case 'a': runtime·printslice(*(Slice*)v); break; case 'd': runtime·printint(*(int32*)v); break; case 'D': runtime·printint(*(int64*)v); break; case 'e': runtime·printeface(*(Eface*)v); break; case 'f': runtime·printfloat(*(float64*)v); break; case 'C': runtime·printcomplex(*(Complex128*)v); break; case 'i': runtime·printiface(*(Iface*)v); break; case 'p': runtime·printpointer(*(void**)v); break; case 's': runtime·prints(*(int8**)v); break; case 'S': runtime·printstring(*(String*)v); break; case 't': runtime·printbool(*(bool*)v); break; case 'U': runtime·printuint(*(uint64*)v); break; case 'x': runtime·printhex(*(uint32*)v); break; case 'X': runtime·printhex(*(uint64*)v); break; } arg = narg; lp = p+1; } if(p > lp) runtime·write(2, lp, p-lp); // unlock(&debuglock); }
void me(string args) { if (strEql(splitArg(args, 1), "setup") || !hasSetup) { if (strEql(splitArg(args, 2), "skip") && !hasSetup) { hasSetup = true; print("\nYou have skipped the Me setup process, some answers may be strange :D",0x06); } else if (!hasSetup) { print("\nWelcome to Me.",0x03); print("\nMe is the worlds first truly rubbish personal assistant.",0x03); print("\nTo use me, simply ask it a question.",0x03); print("\nFor example, type 'me what is the time?'",0x03); print("\nTo start using Me, please enter some basic information below when prompted.",0x03); newline(); newline(); print("What is your name: ",0x0B); readStr(name,128); while (!birthYearValid) { newline(); print("What year were you born in: ",0x0B); readStr(birthYear,5); birthYearInt = stoi(birthYear); // need to make this always the current year + 1 if (birthYearInt < 2016 && birthYearInt > 1900) { birthYearValid = true; print(" Good",0x02); } if (!birthYearValid) { print(" Invalid",0x0C); } } while (!birthDateValid) { newline(); print("What day of the month were you born in: ",0x0B); readStr(birthDate,3); birthDateInt = stoi(birthDate); if (birthDateInt < 32) { birthDateValid = true; print(" Good",0x02); } if (!birthDateValid) { print(" Invalid",0x0C); } } while (!birthMonthValid) { newline(); print("What month were you born in: ",0x0B); readStr(birthMonth,128); birthMonth = toUpper(birthMonth); for(uint32 tmp = 0; tmp < arrLength(months); tmp++) { if (strEql(months[tmp],birthMonth)) { birthMonthValid = true; print(" Good",0x02); } } if (!birthMonthValid) { print(" Invalid",0x0C); } } while (!continentValid) { newline(); print("What continent do you live in: ",0x0B); readStr(continent,128); continent = toUpper(continent); for(uint32 tmp = 0; tmp < arrLength(continents); tmp++) { if (strEql(continents[tmp],continent)) { continentValid = true; print(" Good",0x02); } } if (!continentValid) { print(" Invalid",0x0C); } } while (!countryValid) { newline(); print("What country do you live in: ",0x0B); readStr(country,128); country = toUpper(country); for(uint32 tmp = 0; tmp < arrLength(countries); tmp++) { if (strEql(countries[tmp],country)) { countryValid = true; print(" Good",0x02); } } if (!countryValid) { print(" Invalid",0x0C); } } while (!stateValid) { newline(); print("What state/province do you currently live in: ",0x0B); readStr(state,128); state = toUpper(state); for(uint8 tmp = 0; tmp < arrLength(states); tmp++) { if(strEql(states[tmp],country)) { stateValid = true; print(" Good",0x02); } } if (!stateValid) { print(" Invalid",0x0C); } } newline(); print("What city do you live in: ",0x0B); readStr(city,128); while (!zipValid) { newline(); print("What is the zip/post code in your area: ",0x0B); readStr(zip,17); if (strEql(country,"CANADA")) { print(" Good Enough",0x02); zipValid = true; } else { zipInt = stoi(zip); if (zipInt < 9999999999999999 && zipInt > 0) { zipValid = true; print(" Good",0x02); } if (!zipValid) { print(" Invalid",0x0C); } } } newline(); hasSetup = "true"; print("Me is now ready to use!",0x03); newline(); print("When Me dosen't know information, it can ask you for help.",0x03); } else { print("\nYou have already completed the setup process for Me!",0x05); } } else { bool over = false; int tmp = 0; while (!over) { tmp++; if (strEql(splitArg(args, tmp),"")) { over = true; } else { newline(); printint(tmp,0x0A); print(" : ",0x0B); print(curWord,0x0A); print(" : ",0x0B); printfloat(sort(splitArg(args, tmp)),0x09); } } } }
// Very simple printf. Only for debugging prints. // Do not add to this without checking with Rob. static void vprintf(int8 *s, byte *arg) { int8 *p, *lp; byte *narg; // lock(&debuglock); lp = p = s; for(; *p; p++) { if(*p != '%') continue; if(p > lp) write(fd, lp, p-lp); p++; narg = nil; switch(*p) { case 't': narg = arg + 1; break; case 'd': // 32-bit case 'x': arg = vrnd(arg, 4); narg = arg + 4; break; case 'D': // 64-bit case 'U': case 'X': case 'f': arg = vrnd(arg, sizeof(uintptr)); narg = arg + 8; break; case 'p': // pointer-sized case 's': arg = vrnd(arg, sizeof(uintptr)); narg = arg + sizeof(uintptr); break; case 'S': // pointer-aligned but bigger arg = vrnd(arg, sizeof(uintptr)); narg = arg + sizeof(String); break; case 'a': // pointer-aligned but bigger arg = vrnd(arg, sizeof(uintptr)); narg = arg + sizeof(Slice); break; case 'i': // pointer-aligned but bigger case 'e': arg = vrnd(arg, sizeof(uintptr)); narg = arg + sizeof(Eface); break; } switch(*p) { case 'a': ·printslice(*(Slice*)arg); break; case 'd': ·printint(*(int32*)arg); break; case 'D': ·printint(*(int64*)arg); break; case 'e': ·printeface(*(Eface*)arg); break; case 'f': ·printfloat(*(float64*)arg); break; case 'i': ·printiface(*(Iface*)arg); break; case 'p': ·printpointer(*(void**)arg); break; case 's': prints(*(int8**)arg); break; case 'S': ·printstring(*(String*)arg); break; case 't': ·printbool(*(bool*)arg); break; case 'U': ·printuint(*(uint64*)arg); break; case 'x': ·printhex(*(uint32*)arg); break; case 'X': ·printhex(*(uint64*)arg); break; case '!': ·panicl(-1); } arg = narg; lp = p+1; } if(p > lp) write(fd, lp, p-lp); // unlock(&debuglock); }