Skip to content

Commit

Permalink
precission fix
Browse files Browse the repository at this point in the history
Fixed some glitched numbers
  • Loading branch information
Prevter committed Aug 2, 2020
1 parent fcf748c commit 069c70b
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 4 deletions.
Binary file modified .vs/FloatToolGUI/v16/.suo
Binary file not shown.
71 changes: 67 additions & 4 deletions FloatToolGUI/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,46 @@ public partial class FloatTool : Form
Thread thread1;
public bool muteSound = false;


public static string setprecission(double number, int figures)
{
int e = 0;

while (number >= 10.0)
{
e += 1;
number /= 10;
}

while (number < 1.0)
{
e -= 1;
number *= 10;
}

figures--;

number = (float)Math.Round(number, figures);

figures += 0 - e;
while (e > 0)
{
number *= 10;
e -= 1;
}

while (e < 0)
{
number /= 10;
e += 1;
}

if (figures < 0)
{
figures = 0;
}

return number.ToString($"f{figures}");
}
static public decimal craft(double[] ingridients, float minFloat, float maxFloat)
{
decimal avgFloat = 0;
Expand All @@ -36,6 +75,22 @@ static public decimal craft(double[] ingridients, float minFloat, float maxFloat
avgFloat /= 10;
return ((decimal)(maxFloat - minFloat) * avgFloat) + (decimal)minFloat;
}
static public string craftF(string[] ingridients, float minFloat, float maxFloat)
{
float avgFloat = 0;
float[] arrInput = new float[10];
for (int i = 0; i < 10; i++)
{
arrInput[i] = Convert.ToSingle(ingridients[i].Replace(".", ","));
}
foreach (float f in arrInput)
{

avgFloat += Convert.ToSingle(f);
}
avgFloat /= 10;
return setprecission(((maxFloat - minFloat) * avgFloat) + minFloat, 9);
}
static public string getNextRarity(string rarity)
{
if (rarity == "Consumer")
Expand Down Expand Up @@ -92,18 +147,26 @@ public void parseCraft(double[] inputs, List<dynamic> outputs, string want, bool
float minWear = item["minWear"];
float maxWear = item["maxWear"];
decimal flotOrigin = Math.Round(craft(inputs.ToArray(), minWear, maxWear), 14);
//string flot = ToExactString((double)flotOrigin);
Console.WriteLine(flotOrigin);

string[] inputStr = new string[10];
for(int i = 0; i < 10; i++)
{
inputStr[i] = "" + inputs[i];
}

string flot = craftF(inputStr, minWear, maxWear);
Console.WriteLine(flotOrigin + " | " + flot);
//Debug.WriteLine("[DEBUG] flot = " + flot);
// if (wasSort && ((!asc && (double.Parse(flot) > double.Parse(want))) || (asc && (double.Parse(flot) < double.Parse(want))))) {
// okSort = true;
//}
if (/*flot.StartsWith(want) ||*/ ("" + flotOrigin).StartsWith(want.Replace(".", ",")))
if (flot.StartsWith(want.Replace(".", ",")) || ("" + flotOrigin).StartsWith(want.Replace(".", ",")))
{
this.Invoke((MethodInvoker)(() =>
{
textBox2.AppendText("Коомбинация найдена!" + Environment.NewLine);
textBox2.AppendText("Возможный флоат: " + flotOrigin + Environment.NewLine);
textBox2.AppendText("Проверочный флоат: " + flot + Environment.NewLine);
textBox2.AppendText("Список флоатов: [");
if (!muteSound)
{
Expand Down

0 comments on commit 069c70b

Please sign in to comment.