Float+int math, c++ gcc

Discuss other programming languages besides AutoHotkey
User avatar
Spawnova
Posts: 220
Joined: 08 Jul 2015, 00:12
Contact:

Float+int math, c++ gcc

17 Jun 2017, 20:53

I'm trying to do int*float math, e.g. 5 * 0.5 //2.5 return as int, truncates to 2

However when I compile my c++ code and run it through ahk it returns nothing at all.

C++

Code: [Select all] [Download] GeSHi © Codebox Plus

int function(int value) {
float value2 = 0.5f;
return static_cast<int>(value * value2); //runs into a problem here and returns nothing
}


AHK

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



I'm not sure if I'm doing something wrong, or if it's a compiler issue, was hoping someone could help me out with this.

Return to “Other Programming Languages”

Who is online

Users browsing this forum: No registered users and 1 guest