   Generating Numbers
  Hoi!I need and fast and flexibel way to create numbers. The generator only should need one parameter, the string.Example:HEz -> 501,04750E -> 7509Should I use here a scripting language like lua, or is it better to code it in C?Here is may idea until now:double GeneriereZahl(char* Eingabe){// Eingabe in einen std::string umwandelnstd::string Input = Eingabe;double Ausgabe;// Nun wrid jede Zahl ersetelltfor (int i = 0; i < Input.size(); ++i){// Is es eine Zahl?char Buchstabe = Input.at(i);if (isdigit(Buchstabe) && Buchstabe != ''0''){// so zur Ausgabe hinzufügen// ToDo}else{switch(Buchstabe){case ''e'':Ausgabe += (GetRanNum(1, 9) / 10);break;case ''z'':Ausgabe += (GetRanNum(1, 9) / 100);break;case ''h'':Ausgabe += (GetRanNum(1, 9) / 1000);break;case ''t'':Ausgabe += (GetRanNum(1, 9) / 10000);break;case ''E'':Ausgabe += GetRanNum(1, 9);break;case ''Z'':Ausgabe += (GetRanNum(1, 9) * 10);break;case ''H'':Ausgabe += (GetRanNum(1, 9) * 100);break;case ''T'':Ausgabe += (GetRanNum(1, 9) * 100);break;default:Ausgabe += 0;};}}return Ausgabe;}  One thing might be usefull to know:There should be also support to generate 100 numbersExample:A -> 500A -> 800A -> 300The range for the whole sould be between:999 999, 9999 - 0, 0If you have ideas or ready to sutdy example, let me know it.Thanks to all, Christian 
  I don't think I understand your question, and I can't read your comments. I assume you want to take a string and use it to create a random number between 0 and 1000000. Something like this would work: double GeneriereZahl(const char *Eingabe) {  double Ausgabe = 0;    for(; *Eingabe; ++Eingabe)   Ausgabe += sin(Ausgabe + *Eingabe) * 1000000.0;  while(Ausgabe >= 1000000.0)   Ausgabe -= 1000000.0;  while(Ausgabe < 0.0)   Ausgabe += 1000000.0;    return Ausgabe; } [edited by - smart_idiot on February 13, 2004 10:56:39 PM];  I can   read your comments and I still don''t understand what you''re trying to accomplish. What is the function going to be used for? It could be that you are over-engineering the problem. ;  It seems like he wants to be able to take in a numeric string with wildcards, representing a number in decimal - except that the wildcards are substituted for a random digit.Might I suggest, instead of letter codes for all the wildcards, just use a common symbol like ''*'' or ''?'', and put them in the needed place - writing the decimal point if needed. ThusHEz -> ?0?.0?750E -> 750?This lets you easily specify numbers divisible by 100 (like ?00), and across whatever range you happen to need.Then, in your input routine, just substitute a random digit for a ? if it comes up, and put the digits together like this (pseudocode):total <- 0flag <- false # have we seen the decimal point?places <- 0 # number of decimal placesloop:  char <- stdin  if (char == ''.'') flag <- true  else if (char == ''?'') char <- rand(0..9)  if (char is not a digit) break;  total <- total * 10 + char # this is the key idea you''re probably missing  if (flag) places <- places + 1return total/(10 ** places)  For something like this, your choice of language probably doesn''t matter much. Use whatever is appropriate for everything else that you''re doing. (Like the other posters though, I can''t understand what you need this for.)P.S. Interesting that your comments are actually in German, or are the languages really that similar... ? ;  Zahlman you have it. It is how i want it!Input -> OutputE -> *1E -> 1*TH50 -> **50ZEz -> **,0** stands for a digest [0...9]In the whole i need about 19 different inputchars (e.g E, Z, H,..) and maybe later some more.For instance, i need a chartype, which generates outputs in some ranges.L -> i (i - [2...9])K -> i (i - [1000...9000])So I want a flexible way with not too many inputchars.Maybe i should add 2 paramterts to the function, which are defineing the ranges. 