Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-22-2003, 04:33 AM   #1
LQ Newbie
Registered: May 2003
Posts: 2

Rep: Reputation: 0
Question arithmetic operators in Kylix3 (C++)


When I run a console-app, written in C++ on Borland Kylix - platform = Mandrake 9.0/Intel Celeron - I notice that arythmetic operators used with anything else than integers just don't work.

It seems i can only calculate with ints.
As far as i know all the usual headerfiles are in /usr/include.
Anyway, iostream (iostream.h) should do, no?

I added /usr/include, /usr/include/C++/3.2 , /lib, /lib/include and some other paths in different options of the IDE.

But.....this makes no difference.

I'm new to Kylix (and relatively new to Linux) but I really like this IDE. But if i can only use ints , then of course its useless.

I surely must have overlooked something. Anybody an idea ?


Old 05-22-2003, 05:19 PM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,047
Blog Entries: 11

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Maybe if you were a bit more specific,
like posting the snippet that doesn't work?

Old 05-23-2003, 08:36 AM   #3
LQ Newbie
Registered: May 2003
Posts: 2

Original Poster
Rep: Reputation: 0
well, it's a general problem really.

As long as I use ints in my code, no problem.
But if i use longs, floats or doubles the built application will simply not perform the calculations.

Any example will do, so I taken the calculation of the average in an array of longs.

#include <iostream.h>

using namespace std;

const int size = 5;

int main(){
long array[size] = {x , x, x, x, x } ; //where x is a long
double avg = 0.0;
long res = 0;

for(int i = 0; i < size; i++){
res += array[i];

avg = static_cast <double>(res) / size;

cout << avg << endl;

return 0;

OK, if i compile this piece of code , I just get the output : " 0 ";
Which means the calculations is just not done and the variable avg just keeps its initial value.

I'm really starting to wonder if this is not a general linux problem.
I have this problem on a laptop running Mandrake 9.
On a desktop running Mandrake 8.1 i also use Kylix and there i don't have this problem.
The thing is, i can't always work on my desktop, and i'm not so experienced in both linux and C++ , so i really prefer an IDE over the gcc .


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
simple arithmetic in bash gfrair Linux - Newbie 9 03-16-2005 03:09 PM
Operators *^ and >> GodSendDeath Programming 4 11-01-2004 10:47 PM
operators linuxanswer Programming 3 12-14-2003 07:09 PM
Bash, non-integers and arithmetic causticmtl Programming 5 07-16-2003 10:15 AM
Basic Java arithmetic question chr15t0 Programming 2 07-05-2003 02:32 PM

All times are GMT -5. The time now is 10:18 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration