473,699 Members | 3,186 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to convert float to int in #define statement?

What I really want in the second line of the following code segment is
floor(1000/s)? Is there anyway to do that?

Thanks,
Peng

#define s 1.5433
#define N 1000/s

double a[N];
Nov 14 '05 #1
1 4479

On Mon, 18 Oct 2004, Peng Yu wrote:

What I really want in the second line of the following code segment is
floor(1000/s)? Is there anyway to do that?

Thanks,
Peng

#define s 1.5433
#define N 1000/s

double a[N];


double a[(int)(1000/s)];

ought to do the trick. Your subject line really says all you needed to
know: to convert any type to 'int', just convert it to 'int' (with a
cast).

-Arthur
Nov 14 '05 #2

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

Similar topics

5
175412
by: Konrad Mühler | last post by:
Hi, a simple question but i found no solution: How can i convert a float value into a string value? string_value1 = string(float_value) + ' abc'
4
23165
by: jaijai_kumar | last post by:
Select Cast('100.1234' as float) give me the result 100.1234 Now when I convert it back to char I want exactly 100.1234 Select Convert(char(100),Cast('100.1234' as float)) Gives me 100.123 (Here I was expecting 100.1234) When I do Select STR(Cast('100.1234' as float),25,4) I get back the result as 100.1234
9
90338
by: FalkoG | last post by:
Hello colleague I want to convert a floating number for example 5236.9856982 to a hexadecimal number. I'd tried several things but my problem is to convert the position after decimal point. I searched numberless websites but nothing could answer my question. I would be pleased to get some help. Regards
4
25085
by: Pixie Songbook | last post by:
Hi, I'm trying to write a program using the Dev C++ 4.9.9.2 compiler that takes input numbers from a word document, sums them together, and then gives me a result. It should be easy as the book I have tells me what to do, problem is I get the error message "cannot convert `float' to `float*' for argument `1' to `float array_sum(float*, int)' " for line 22 of the program. This is what I have; #include <iostream.h> #include <fstream.h> ...
2
6892
by: lisasahu | last post by:
how to convert float to string like there is atof atoi and itoa but is ther any method to convert float to string
5
3264
by: sidhuasp | last post by:
Hi could anyone please tell me how to convert float value in my database ti HOUR/MIN format for my timesheet requirement. i have to do it in sql-reporting services
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 ___________________________________
9
5118
by: tvnaidu | last post by:
I am doing floating point calculation inside C function, with debugger I can see float values in single step, if I want to print them on console, I am using printf, but printf not working for flaot, how can I convert them to int and print on console using printf. I tried to print with %d, but float, but not printing, any idea?. Thanks.
0
9187
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
9053
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...
1
8936
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8894
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
7776
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
4636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3071
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2360
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2015
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.