Jump to content
Tuts 4 You

How to calc with div & mul?


LCF-AT

Recommended Posts

It's not "wrong" but ADD is preferred way. Ur way will take ~ same amount of code as ADD - u r using static globals already mov'd into sscan, but in real program it'd be dynamic locals on the stack so u'd need more movs.

ADD is doing DWORD math, FADD is doing QWORD math when all we need is DWORD so on x86 ADD is a bit faster in this case, probably for more reasons too (tested using ./time). i'd use FPU for square root or similar, but not addition.

Link to comment
  • 2 months later...

Hi again,

short question.I got some trouble again with the sscanf API so I wanna know how to convert a "double" into string.So I can use this API to make a double of a string but I need the other way so how to do this?

String to double

invoke crt_sscanf,chr$("480"),chr$("%lf"),addr BACKWQ
=
$ ==>    00000000
$+4      407E0000
-----------------------------
Now I need to get the 480 string from the double but how?

Maybe you can help me again a little.Thanks.

greetz

Link to comment

Hi kao,

so I need to know the signs I have to use with that API wsprintf you know %xy <---?So what to use?

invoke wsprintf,addr BUFFA2,chr$("%??"),[BACKWQ]

Thanks

Link to comment

%lf dosen't work with wsprintf if I push the double.Only get "f" back in buffer.By the way,found a FloatToStr macro what does do it right for me to change double to string. :) 

greetz

Link to comment

My mistake, apparently wsprintf doesn't like floating point numbers. sprintf should work though.

Glad you found another solution! :)

Link to comment

 

 

Quote

By the way,found a FloatToStr macro what does do it right for me to change double to string. :) 

 

Is a really wrong and a dirty way, i have tell you for month´s  with Qwords

 

 

Edited by ragdog
Link to comment

Hi raggy,

this is now something else Burli. :) In the past I had a string I wanted to change in a QWORD or also hexbytes (adding over -1) in QWORD and there I used I64d with sscanf but now I have the other case to handle and only have double to change to string.I'll show you..

string 240 to double
=
invoke crt_sscanf,chr$("240"),chr$("%lf"),addr BACKWQ // BACKWQ   QWord ?
=
$ ==>    00000000
$+4      406E0000

Ok,on that way I can change strings to double.
But how to get the string if I just have the double?

invoke wsprintf,addr BUFFA2,chr$("%I64d"),[BACKWQ]
=
$ ==>    > 0040107E  /CALL to wsprintfA from bones.00401079
$+4      > 00403034  |s = bones.00403034
$+8      > 00403008  |Format = "%I64d"
$+C      > 00000000
$+10     > 406E0000
=
4642648265865560064 // wrong.Also wsprintf API dosent look correctly

If I use...

invoke FloatToStr,[BACKWQ],addr BUFFA2
or
invoke FloatToStr2,[BACKWQ],addr BUFFA2
=
240  <--- Ok

So just tell me how the right API use was so I can't find the other way in my notes anymore or lost overview from tons of different examples.

greetz & Happy Osterei :) du Ei ;)

Link to comment

We have long talk about qword´s, months ago and now have you all forgot?

A float is what other a Float is a example 1.0  "Floating point numbers"  .PUNKT

https://translate.google.de/?hl=de#en/de/Floating%20point%20numbers

You have a dezimal Number Not a floating point Number !!!!!!

If you use apis can you use

.data?
BACKWQ   QWord ?
.code
start:
invoke crt_sscanf,chr$("240"),chr$("%I64d"),addr BACKWQ 
invoke wsprintf,addr plainbuff,chr$("%I64d"), BACKWQ 

It gives many way to convert a decimal number to dword/qword and back StrToInt/StrToInt64  or other Apis/Procedurs but not use Floating points Procedurs.

And is your number "240" a qword? F0 is a byte

You cannnot use any functions and say EGAL HAUPTSACHE ES FUNKTIONIERT

Edited by ragdog
Link to comment

Hi again,

so I dont have F0 hex value in buffer as I told before.Just try my example above and use %lf to make a double from a string value and now try to find the other way to make a string from the double.So what to use in that case instead to use the FloatToStr macro what does do it right and what is what I need at the moment?

greetz

Link to comment
  • 1 year later...

Hi guys,

I have again a little calculation question.How can I calculate the percent value (0 - 100 %) if I just know the running file runtime?So I dont have the filesize in this case.

Lets say  the file I wanna download has a runtime lenght of 10 seconds and thats the only info I have.10 seconds = 100 %.So now I think I have to calc with the downloaded sizes parts anyhow or I  need to set time markers or so etc to calc a actually downloaded percent value.Can anyone help again?The calc operations is always my Achilles-Heel.

greetz

Link to comment
Teddy Rogers

If I understood you correctly, is MulDiv what you are after?

Time = 11
FileSize = 3200
Percentage = 100

Debug MulDiv_(Time, FileSize, Percentage)

Ted.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...