473,809 Members | 2,809 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

float to integer convertion

I have this functions, c3 and c2 that computes and return a float
number. The problem is that wen I pass the result of c2 (float number)
to c3(), in function apears to be an integer. Ex.:
$calc2=c2(param s); (float number)
$calc3=c3($calc 2); ($calc2 - float number)
echo $calc3; (is not the number that supposed to be, because c4
computes $calc2 as if it were an integer: if $calc=39.96 it wil be
converted in 39).

What is the problem? I really can't see it.

_____

function c2($j,$n)
{
//=(J54*100)/N47
$c=$j*100/$n;
return number_format($ c,2,",",".");
}

function c3($calc)
{
//=((16*M54)/100)+4
$c=((16*$calc)/100)+4;
return number_format($ calc,2,",",".") ;
}
______

Sep 21 '06 #1
1 2163
iulian.ilea wrote:
function c3($calc)
{
//=((16*M54)/100)+4
$c=((16*$calc)/100)+4;
return number_format($ calc,2,",",".") ;
}
$c=((16*$calc)/100)+4; --$c variable never been used

return number_format($ calc,2,",",".") ; --it will format the input
number $calc

---
http://www.groupvita.com
http://www.deshot.com

Sep 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2092
by: Bengt Richter | last post by:
Peculiar boundary cases: >>> 2.0**31-1.0 2147483647.0 >>> int(2147483647.0) 2147483647L >>> int(2147483647L ) 2147483647 >>> >>> -2.0**31
7
1704
by: nephish | last post by:
Hullo all ! i have a real easy one here that isn't in my book. i have a int number that i want to divide by 100 and display to two decimal places. like this float(int(Var)/100) but i need it to display the .00 even if it does not have a .00 value like this if Var is 50, i need to display .50 instead of just .5
9
2372
by: Nicolas Blais | last post by:
Hi, I have this following class which I use as a timer: #include <sys/time.h> using namespace std; class chrono { public: chrono() {};
1
2892
by: omariqbalnaru | last post by:
Can anybody please explain to me what the statment floatptr=(float*) intptr; does?
116
36012
by: Dilip | last post by:
Recently in our code, I ran into a situation where were stuffing a float inside a double. The precision was extended automatically because of that. To make a long story short, this caused problems elsewhere in another part of the system where that figure was used for some calculation and some eventual truncation led to the system going haywire. So my question is, given this code: int main() { float f = 59.89F;
2
817
by: ireyes | last post by:
DEAR SIR, I SAW YOUR INTERNET QUESTION AND I HAVE THE SAME TROUBLE. CUOLD YOU HELP ME TO MAKE A FLOAT TO INTEGER CONVERTION? DO YOU HAVE ANY EXEL FILE THAT CAN DO THAT? REGARDS AND THANKS A LOT IVAN REYES ___________________________________
4
1474
by: Yuan HOng | last post by:
Hi, It seems decimal object will always be larger than float in comparasion, which goes against common sense: False True It seems to me that rather than allowing this to happen, comparasion between the two should either be made correct (by convertion decimal
0
814
by: Wojciech Walczak | last post by:
2008/5/6, Yuan HOng <hongyuan1306@gmail.com>: Looks like a nasty bug. a 99999.0 returns True because NotImplemented 99999.0 returns True. a < 99999.0 returns False because NotImplemented < 99999.0 returns False. As you can see the real comparision has nothing to do with your Decimal number. I think you can report it at bugs.python.org.
22
2780
by: Bill Reid | last post by:
I just noticed that my "improved" version of sscanf() doesn't assign floating point numbers properly if the variable assigned to is declared as a "float" rather than a "double". (This never cropped up before, since I rarely use "float"s for anything, and hardly ever use the function for floating-point numbers in the first place; I just was messing around testing it for all cases and noticed a problem.) Anyway, it is declared and I...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10639
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.