Qui si parla italiano
 Page:1

# TOPIC:

## Cosa sbaglio? 21 Aug 2019 10:06 #10255

 Topic Author Posts: 174 LOCAL nDec AS System.Double oppure AS FLOAT oppure AS System.Decimal nDec := (56/39) torna sempre 1 e non 1,43.... grazie Danilo Please Log in or Create an account to join the conversation.

## Cosa sbaglio? 21 Aug 2019 10:39 #10256

 Juraj Posts: 158 maybe my attempt will help LOCAL nDec as Decimal nDec:=(57./36.) return 1.46 Juraj Please Log in or Create an account to join the conversation.

## Cosa sbaglio? 21 Aug 2019 10:44 #10257

 FFF Posts: 1392 Works, if you write either number with a ".0" But this is certainly a bug Regards Karl (X# 2.14.0.4; Xide 1.33; W8.1/64 German) Please Log in or Create an account to join the conversation. Last edit: by FFF.

## Cosa sbaglio? 21 Aug 2019 10:48 #10258

 wriedmann Posts: 3245 Ciao Danilo, Juraj is right. "57" e "39" sono considerati tipo integer, perciò il risultato sarà int, se non imposti /vo12 ("Integer divisions return float"). Altra possibilità:```nDec := (56d/39d) nDec := (56m/39m)``` Vedi: docs.xsharp.it/doku.php?id=literals Saluti Wolfgang Wolfgang Riedmann Meran, South Tyrol, Italy www.riedmann.it - docs.xsharp.it Please Log in or Create an account to join the conversation.

## Cosa sbaglio? 21 Aug 2019 10:52 #10259

 Juraj Posts: 158 just one with a dot (57./39) or (57/39.) return 1.46 Please Log in or Create an account to join the conversation.

## Cosa sbaglio? 21 Aug 2019 10:58 #10260

 wriedmann Posts: 3245 Hi Karl, this is not a bug. If the /vo12 compiler option is not selected, every division by integers return an integer. VO behaves the same. Wolfgang Wolfgang Riedmann Meran, South Tyrol, Italy www.riedmann.it - docs.xsharp.it Please Log in or Create an account to join the conversation.

## Cosa sbaglio? 21 Aug 2019 11:33 #10263

 FFF Posts: 1392 Wolfgang, i see. Hadn't thought that this may be the case even in core And, as i just found out, it does not. Setting /vo12 makes the compile fail. For reference tried in c#, the results are the same. So, it's one of these pitfalls, one has to keep in mind.... I think, i'd prefer the opposite behaviour as default, as i can't think of a lot of showcases, where one works on literal ints and wants to get the truncated result. But that's just me Regards Karl (X# 2.14.0.4; Xide 1.33; W8.1/64 German) Please Log in or Create an account to join the conversation. Last edit: by FFF.

## Cosa sbaglio? 21 Aug 2019 12:02 #10264

 Karl-Heinz Posts: 774 funny, i firstly thought my cpu is defect, until i´ve noticed that there are different division that cause of course different results (56/39) (57./36.) (57./39) here´s another float result option ? (decimal) 56/39 ? (double) 56/39 ? (FLOAT) 56/39 regards Karl-Heinz Please Log in or Create an account to join the conversation.

## Cosa sbaglio? 21 Aug 2019 12:07 #10265

 Topic Author Posts: 174 Thanks to all Danilo Please Log in or Create an account to join the conversation.

## Cosa sbaglio? 21 Aug 2019 13:49 #10269

 wriedmann Posts: 3245 Hi Karl,And, as i just found out, it does not. Setting /vo12 makes the compile fail. For reference tried in c#, the results are the same. So, it's one of these pitfalls, one has to keep in mind.... I think, i'd prefer the opposite behaviour as default, as i can't think of a lot of showcases, where one works on literal ints and wants to get the truncated result. But that's just me so the behaviour of C# is the same as VO and X#.... I would also prefer to have the same as default - had similar problems several times in my VO applications, and therefore I'm always writing numeric literals with decimal point and 0 when dividing, and casting integer variables to float. But compatibility is important, and changing it would break really a lot of code. And I can understand why /vo12 makes the compile fail on Core dialect: there is no float datatype. Wolfgang Wolfgang Riedmann Meran, South Tyrol, Italy www.riedmann.it - docs.xsharp.it Please Log in or Create an account to join the conversation.
 Page:1
Moderators: wriedmann