![]() |
equivalent für wcstof
Wieder ein C++ 64Bit zu Delphi Problem.
In C++ verwende ich 'wcstof' um das Rating System für meinen Player zu berechnen.
Code:
Nun benötige ich einen vergleich um das auch in Delphi 32 Bit umzusetzen.
long ComputeStarRate() {
long nRate = 0; WCHAR* stopstr = NULL; float rating = wcstof(gM.vote_average, &stopstr); rating += wcstof(gM.popularity, &stopstr) / 100.0f; nRate = min(max(roundL(rating * 10), 0), 100); return nRate; } Hat vielleicht jemand eine Idee wie ich das bewerkstelligen könnte? Ich habe zwei Bitmaps die ich überlagere. Das Hintergrund Bitmap soll dann in der weite entsprechend der 'vote_average <> popularity' geändert werden. gruss |
AW: equivalent für wcstof
Hängt ein bisschen von Deinem InputString ab
Ist Deinem Fall (den ich kenne) StrToFloat() |
AW: equivalent für wcstof
Bin am überlegen ob ich nicht hingehe und nur das reine Rating in Delphi verwende das vereinfacht das ganze etwas.
gM.vote_average Zitat:
gruss |
AW: equivalent für wcstof
Rating funktioniert wie es soll.
Delphi-Quellcode:
gruss
function ComputeStarRate: LongInt;
var FS: TFormatSettings; nRate: LongInt; rating: Single; average, popularity: single; begin FillChar(FS, SizeOf(FS), 0); FS.DecimalSeparator := '.'; average := StrToFloat(gM.vote_average, FS); FillChar(FS, SizeOf(FS), 0); FS.DecimalSeparator := '.'; popularity := StrToFloat(gM.popularity, FS); rating := average + (popularity / 150.0); nRate := min(max(round(rating * 15), 0), 150); result := nRate; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:40 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz