Register
Sponsored By
BlackBerryFAQ
Search
Today's Posts
Mark Forums Read
BlackBerry Forums Support Community
BlackBerry Technical
Developer Forum
Divide By 100 - JDE 4.7
LinkBack
Thread Tools
03-20-2009, 10:46 AM
#
1
(
permalink
)
DD12
Thumbs Must Hurt
Join Date: Jan 2009
Model:
9530
PIN:
N/A
Carrier:
Telus
Posts: 107
Post Thanks: 0
Thanked
0 Times in 0 Posts
Divide By 100 - JDE 4.7
Please Login to Remove!
Hello Everyone
I am dividing a int by 100 and storing the result in float. The result I get is 0.0
int abc = 15;
float xyz = 15/100;
the result is 0.0.
What am I doing wrong?
Thanks
Offline
03-20-2009, 11:10 AM
#
2
(
permalink
)
Dougsg38p
BlackBerry Extraordinaire
Join Date: Mar 2008
Location: Austin, TX
Model:
9700
PIN:
N/A
Carrier:
T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked
34 Times in 33 Posts
(int) 15 / 100 = 0.15
This result is then truncated when forced into an int (intermediate) value, so it becomes zero.
Try this:
float xyz = 15.0 / 100.0;
Last edited by Dougsg38p : 03-20-2009 at
11:12 AM
.
Offline
03-20-2009, 11:33 AM
#
3
(
permalink
)
DD12
Thumbs Must Hurt
Join Date: Jan 2009
Model:
9530
PIN:
N/A
Carrier:
Telus
Posts: 107
Post Thanks: 0
Thanked
0 Times in 0 Posts
It worked.
Thanks Dougsg38p.
Offline
03-23-2009, 12:03 AM
#
4
(
permalink
)
baskaraninfo
Knows Where the Search Button Is
Join Date: Feb 2009
Location: Bangalore
Model:
9350
PIN:
N/A
Carrier:
Telstra
Posts: 29
Post Thanks: 0
Thanked
0 Times in 0 Posts
float xyz = (float) 15/100;
You can even try this DD12
Offline
«
My application is not appear in Simulator
|
How do implement AutoSuggest in a native Blackberry application..
»
Thread Tools
Show Printable Version
Email this Page
Posting Rules
You
may not
post new threads
You
may not
post replies
You
may not
post attachments
You
may not
edit your posts
vB code
is
On
Smilies
are
On
[IMG]
code is
On
HTML code is
Off
Trackbacks
are
On
Pingbacks
are
On
Refbacks
are
On
Pipe Clamp Temperature Lead K-Type Probe Thermocouple Sensor -40 EO56
$8.27
TM-902C Instruments K Type Thermocouple Probe Single Input LCD Thermometer
$5.63
MAX6675 Module+ K Type Thermocouple Temperature Sensor M6 for Arduino 5V Newest
$4.99
MAX6675 Module+ K Type Thermocouple Temperature Sensor M6 for Arduino 5V Nice
$4.49
MAX6675 Module + K Type Thermocouple Temperature Sensor M6 for Arduino DC 5V x1
$5.53
Copyright © 2004-2016
BlackBerryForums.com
.
The names
RIM ©
and
BlackBerry ©
are registered Trademarks of
BlackBerry Inc.
Contact Us
-
BlackBerryForums.com
-
Archive
-
Top
LinkBack
LinkBack URL
About LinkBacks
Bookmark & Share
Digg this Thread!
Add Thread to del.icio.us
Bookmark in Technorati
Tweet this thread