Is there any way to split a number into its integer and decimal parts?
I've tried the int() "function":
int(5.5) = 5.
But I've got no idea how do I get the decimal?
Example:
(I have)
a = 12.34
(I want)
b = 12
c = 34
a = 12.34
b = int(a)
c = ????
Thanks!!!!
(Update)
My specific problem, here we have (thanks again for the support)
I have a set of data, with different blocks. For each block, I want to make the same plot. The title of the plot and the name of the output png depends on the block.
With this goal in mind I've created a loop
do for [j=0:int(A_blocks-2)]{
i=0 + 0.4*j
set output 'Mz_NMcs5000_Hext'.i.'_JC1_JSn05_JIntn05_R11_tSh2.png'
set title "H = '.i.' J_C = 1 J_S = J_{Int} = - 0.5"
plot filename index j using 1:5 w lp pt 5 lt rgb "black" title "Mag_T", "" index j u 1:20 w lp pt 9 lt rgb "red" title "Mag_{Int-S}"
}
The problem I have is that I only can concatenate using the dot if the value is an integer. I get this error:
internal error : STRING operator applied to undefined or non-STRING variable
If you want to include a float number into a title or a file name use the string formatting via sprintf()
, check help sprintf
and help format specifiers
.
a = 1.234
myFile = sprintf("MyFileName_%g_MoreParameters.png",a)
print myFile
Result:
MyFileName_1.234_MoreParameters.png