The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Divide

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Rimmer Posted - 11/15/2003 : 05:15:05 AM
Sorry for the extremely basic question, but I have two ints x1 and x2 and a double scalex. However when I write

scalex = x1 / x2

the result in scalex is always an integer and not the double that I require.

Why do I have this behaviour?

Thanks

Mick
3   L A T E S T    R E P L I E S    (Newest First)
cpyang Posted - 11/15/2003 : 4:35:01 PM
That is how it is in C/C++, when doing arithmetics between integers, then the result is also must be an integer, so must cast at least one value into double so that the arithmetics will result into double.

CP


Rimmer Posted - 11/15/2003 : 1:16:11 PM
Thanks that worked

Seems strange to have to cast in such a simple case

Mick
Mike Buess Posted - 11/15/2003 : 09:11:02 AM
Hi Mick,

Try this...

scalex = (double) x1 / x2;

Mike Buess
Origin WebRing Member

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000