Skip to content

Commit

Permalink
finished output system
Browse files Browse the repository at this point in the history
it now can calculate ieee754 from the float, price and print results from "less" and "greater" modes
  • Loading branch information
Prevter committed Apr 21, 2022
1 parent b8c0c39 commit 613c2ce
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions FloatTool/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,30 @@ private void FloatCraftWorkerThread(CraftSearchSetup options)
gotResult = Math.Abs(resultFloat - options.SearchTarget) < options.TargetPrecision;
break;
case SearchMode.Less:
decimal neededLess = decimal.Parse(options.SearchFilter, CultureInfo.InvariantCulture);
gotResult = resultFloat < neededLess;
gotResult = resultFloat < options.SearchTarget;
break;
case SearchMode.Greater:
decimal neededGreater = decimal.Parse(options.SearchFilter, CultureInfo.InvariantCulture);
gotResult = resultFloat > neededGreater;
gotResult = resultFloat > options.SearchTarget;
break;
}

if (gotResult)
{
if (options.SearchMode == SearchMode.Equal)
if (options.SearchMode != SearchMode.Equal ||
Math.Round(resultFloat, 14, MidpointRounding.AwayFromZero)
.ToString(CultureInfo.InvariantCulture)
.StartsWith(options.SearchFilter, StringComparison.Ordinal))
{
float price = 0;
float ieeesum = 0;
foreach (var skin in resultList)
{
price += skin.Price;

ieeesum += (float)skin.WearValue;
}
ieeesum /= 10;
float ieee = ((float)options.Outcomes[i].MaxFloat - (float)options.Outcomes[i].MinFloat) * ieeesum + (float)options.Outcomes[i].MinFloat;

Dispatcher.Invoke(new Action(() =>
{
ViewModel.FoundCombinations.Add(new Combination
Expand All @@ -162,7 +169,8 @@ private void FloatCraftWorkerThread(CraftSearchSetup options)
OutcomeName = options.Outcomes[i].Name,
Inputs = resultList,
Currency = resultList[0].SkinCurrency,
Price = price
Price = price,
IEEE754 = ((double)ieee).ToString("0.000000000000000", CultureInfo.InvariantCulture)
});
}), DispatcherPriority.ContextIdle);
}
Expand Down

0 comments on commit 613c2ce

Please sign in to comment.