AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Limiting decimal part of a float. (https://forums.alliedmods.net/showthread.php?t=113809)

01101101 12-30-2009 10:28

Limiting decimal part of a float.
 
Who wants to show the 15 numbers decimal number?
%01f just doesn't work.

ehha 12-30-2009 10:32

Re: Limiting decimal part of a float.
 
Try %0.15f or %15.0f, I don't understand witch part do you want, before or after "."

01101101 12-30-2009 10:34

Re: Limiting decimal part of a float.
 
Quote:

Originally Posted by ehha (Post 1036486)
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 12-30-2009 10:37

Re: Limiting decimal part of a float.
 
Nevermind, worked as expected.

%0.1f will show

123.1 for example.

ehha 12-30-2009 10:37

Re: Limiting decimal part of a float.
 
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.

01101101 12-30-2009 10:50

Re: Limiting decimal part of a float.
 
Quote:

Originally Posted by ehha (Post 1036493)
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.

Arkshine 12-30-2009 12:09

Re: Limiting decimal part of a float.
 
http://www.cplusplus.com/reference/c...stdio/fprintf/

it uses the same syntax except some things which won't work in pawn.

rx1983 11-19-2011 09:00

Re: Limiting decimal part of a float.
 
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?

Backstabnoob 11-19-2011 09:03

Re: Limiting decimal part of a float.
 
Round it and display it as an integer?

rx1983 11-19-2011 09:13

Re: Limiting decimal part of a float.
 
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 ??????


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

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