calculation error

Having trouble with the game? Report issues and get help here. Read this first!

Moderator: Forum Moderators

Forum rules
Before reporting issues in this section, you must read the following topic:
Post Reply
User avatar
Blitzmerker
Posts: 50
Joined: March 20th, 2007, 5:44 pm
Location: Germany

calculation error

Post by Blitzmerker »

Hi all,

I have the problem:
when wesnoth 1.4/1.5+svn (running on ubuntu 7.10) is calculating 100 * 0.3

Code: Select all

[set_variable]
    name=calc
    value=100
[/set_variable]
[set_variable]
    name=calc
    multilpy=0.3
[/set_variable]
[message]
    speaker=narrator
    message="$calc"
[/message]
the result is 29 (not 30).
The c++ program

Code: Select all

#include <iostream>
using namespace std;
int main()
{
    int calc = 100;
    calc = calc * 0.3;
    cout << calc;
    return 0;
}
also gives the result 29. If "float" is used instead of "int" the result is 30.
Why is 100 * 0.3 = 29?
:(){ :|:& };:
Post Reply