Old 4th August 2002, 05:03   #1
cchian
Member
 
Join Date: Apr 2001
Posts: 73
Numeric calculations including fractions?

I am trying to divide a number by another one which is not an integer (ie 1234 divided by 56.789). Is this possible? So far I have only been able to get the answer as an integer (using IntOp).
cchian is offline   Reply With Quote
Old 4th August 2002, 10:09   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
NSIS only deals with integers, sorry... You can always use an external DLL.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 5th August 2002, 02:16   #3
cchian
Member
 
Join Date: Apr 2001
Posts: 73
Thanks for responding Kichik.
cchian is offline   Reply With Quote
Old 6th August 2002, 09:20   #4
CodeSquid
Member
 
Join Date: Dec 2001
Posts: 89
Well, try the following:

StrCpy $1 33
StrCpy $2 88
; 33/88=0.375
IntOp $1 $1 * 1000
IntOp $3 $1 / $2 ; $3 is now 375

; Now try to output $3:
IntOp $4 $3 / 1000
IntOp $5 $3 % 1000
MessageBox MB_OK "$4.$5" ; output the number, in this case 0.375

Exchange 1000 with a greater value if you need more digits after the .
CodeSquid is offline   Reply With Quote
Old 6th August 2002, 17:33   #5
cchian
Member
 
Join Date: Apr 2001
Posts: 73
Thanks for your suggestion. What I wanted to do was to divide a number (integer) by something that is not an integer (ie 5.789). In your example, if I assign 5.789 to $2, the calculation with IntOp would ignore anything after the decimal point. It will be like 33/5 instead of 33/5.789
cchian is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump