Raised This Month: $ Target: $400
 0% 

Limiting decimal part of a float.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
01101101
BANNED
Join Date: Nov 2009
Location: 9`su 09`n0n7e`r0f76a
Old 12-30-2009 , 10:28   Limiting decimal part of a float.
Reply With Quote #1

Who wants to show the 15 numbers decimal number?
%01f just doesn't work.
01101101 is offline
ehha
SourceMod Donor
Join Date: Apr 2006
Location: Sibiu
Old 12-30-2009 , 10:32   Re: Limiting decimal part of a float.
Reply With Quote #2

Try %0.15f or %15.0f, I don't understand witch part do you want, before or after "."
__________________

Last edited by ehha; 12-30-2009 at 10:35.
ehha is offline
01101101
BANNED
Join Date: Nov 2009
Location: 9`su 09`n0n7e`r0f76a
Old 12-30-2009 , 10:34   Re: Limiting decimal part of a float.
Reply With Quote #3

Quote:
Originally Posted by ehha View Post
Try %0.15f
So, with %0.3f will it display something like:
15.432

Or because of the "0" it has just will display

.432
01101101 is offline
01101101
BANNED
Join Date: Nov 2009
Location: 9`su 09`n0n7e`r0f76a
Old 12-30-2009 , 10:37   Re: Limiting decimal part of a float.
Reply With Quote #4

Nevermind, worked as expected.

%0.1f will show

123.1 for example.
01101101 is offline
ehha
SourceMod Donor
Join Date: Apr 2006
Location: Sibiu
Old 12-30-2009 , 10:37   Re: Limiting decimal part of a float.
Reply With Quote #5

I'm not sure what 0 does, but if you want 15 digits after "." and X digits before use %X.15f, if %0.15f fails.
__________________
ehha is offline
01101101
BANNED
Join Date: Nov 2009
Location: 9`su 09`n0n7e`r0f76a
Old 12-30-2009 , 10:50   Re: Limiting decimal part of a float.
Reply With Quote #6

Quote:
Originally Posted by ehha View Post
I'm not sure what 0 does, but if you want 15 digits after "." and X digits before use %X.15f, if %0.15f fails.
0 means no limit. If I used

%1.1f it will show 1 absolute digit, 1 decimal digit.
01101101 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-30-2009 , 12:09   Re: Limiting decimal part of a float.
Reply With Quote #7

http://www.cplusplus.com/reference/c...stdio/fprintf/

it uses the same syntax except some things which won't work in pawn.
__________________
Arkshine is offline
rx1983
Senior Member
Join Date: Jan 2009
Location: BRASIL
Old 11-19-2011 , 09:00   Re: Limiting decimal part of a float.
Reply With Quote #8

still can not understand how to display the integer part of a float.

example:

a = 123.456

Archine, how can I display the "123"??
appear without the dot "." ?


PHP Code:
client_print(0print_chat"[csro] Frags: %.0f "frags[bestplayer]); 
output: "123."

this way I can view the entire piece, but it appears the "."

display only the decimal part?
__________________
rx1983 is offline
Send a message via MSN to rx1983
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 11-19-2011 , 09:03   Re: Limiting decimal part of a float.
Reply With Quote #9

Round it and display it as an integer?
Backstabnoob is offline
rx1983
Senior Member
Join Date: Jan 2009
Location: BRASIL
Old 11-19-2011 , 09:13   Re: Limiting decimal part of a float.
Reply With Quote #10

I tried to explain the best way, but do not understand what you wrote, I do not speak English.

I want to format the floating and take only the integer part, how can I do this ??????
__________________
rx1983 is offline
Send a message via MSN to rx1983
Reply



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

Forum Jump


All times are GMT -4. The time now is 04:16.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode