print using "###.##" (resolved)

General FreeBASIC programming questions.
Post Reply
Luis antonio Porto
Posts: 18
Joined: Feb 13, 2006 12:34
Location: brasil
Contact:

print using "###.##" (resolved)

Post by Luis antonio Porto »

Hello friends.

Please, when I use

Print using " ###.# "; 1.19

the result is 1.1 and not 1.2 !

How do I solve this problem ?

tks
Vendan
Posts: 48
Joined: Sep 18, 2006 0:25

Post by Vendan »

Hrm, check your fbc version. I just tried it and it printed out 1.2
fxm
Moderator
Posts: 12549
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Post by fxm »

Vendan wrote:Hrm, check your fbc version. I just tried it and it printed out 1.2
You have a very old fbc version, because it was fixed from fbc version 0.16!
ytwinky
Posts: 217
Joined: Dec 03, 2005 12:44
Location: MD, Germany

Post by ytwinky »

hi,
Vendan wrote:..I just tried it and it printed out 1.2
same here(XP, SP3 etc., FB0.22, FBEdit 1.0.7.6c)
you could also try

Code: Select all

#include "vbcompat.bi"
Print Format(1.19, "##.#")
regards
ytwinky
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: print using "###.##"

Post by TJF »

Luis antonio Porto wrote:Print using " ###.# "; 1.19

the result is 1.1 and not 1.2 !

How do I solve this problem ?

Code: Select all

#IF __FB_VERSION__ < "0.16"
CONST ROUND_FIX1 = .05
#ELSE
CONST ROUND_FIX1 = .0
#ENDIF

Print using " ###.# "; 1.19 + ROUND_FIX1
fxm
Moderator
Posts: 12549
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Post by fxm »

Whatever the fbc version:

Code: Select all

Print using " ###.# "; Cint(1.19 * 10) / 10
Luis antonio Porto
Posts: 18
Joined: Feb 13, 2006 12:34
Location: brasil
Contact:

print using "###.##" resolved

Post by Luis antonio Porto »

Several solutions, some very interesting, thank you (all)

Luis
Post Reply