Smarty Float format thousands without php? - smarty

So, I'm trying to make smarty format a number like 1000.66 to 1,000.66 but when I use {$number|number_format:0:'.':','} it just rounds it up to 1,001...
I've googled but I can't find anything about it...

|number_format just uses the php function of the same name. Your problem is that you specified the number of decimals as 0, and the function rounds up the number provided. Try with
{$number|number_format:2:'.':','}

Related

IMPORTXML value returned price NOT as number - need help to convert

Not an expert in Google sheet so would appreciate if someone can help me solve this:
trying to do some work on crypto pricing.
I extract the actual price this way
CELL I2 has something like https://coinmarketcap.com/currencies/AAVE
If I use formula =IMPORTXML(I2,"//div[#class='priceValue ']")
It will return the price value of the I2 crypto in this case for example $320.12
It seems the 320.12 is text and I could not convert to number using VALUE(I2)
I need to use this 320.12 to calculate ...
for example I try to multiply the 320.12 by the quantity and I get the error: Function MULTIPLY parameter 1 expects number values. But '$320.12' is a text and cannot be coerced to a number.
Appreciate the help
use:
=1*REGEXEXTRACT(IMPORTXML(I2, "//div[#class='priceValue ']")&"", "\d+.\d+|\d+")
No the value is a number formatted in $, you can use it ... see https://docs.google.com/spreadsheets/d/1cgb8D01AR7Zy6FVjYcVtJkNk1lEtRC7V_UvjcF283qA/edit?usp=sharing

How to format a number with XPath in Tibco BW 5

I've managed to format the following lines in XPath, from this format:
1000.50
30
to this:
100050
3000
The solution I've adopted is:
concat(substring-before([number], '.'), substring-after([number], '.'))
If the . is not present I directly multiply the number by 100.
I'm wondering if there is any better way to do that. My second thought was using Java.
What goes wrong if you just multiply by 100? So long as the result of multiplying by 100 is an exact integer, it should be formatted without a "." when converted to a string. If there are rounding errors that mean the result is not an exact integer, you might want to use round().
The concat() approach seems fragile to me: what if someone gives you input like 1000.5 or perhaps 1000.500?

rounding a number in ruby

I would like to round this figure to the nearest whole number. I am generating an xml based on an excel file, and would like to round the figure.
Here is my code:
xml.POS110 “wert”: “#{row[18]}”
I have tried:
xml.POS110 “wert”: “#{row[18]}”.round(0)
Move the round inside the quotes. Before, you were just trying to round a string. Also the default argument for round is 0 so you don't need to specify it (but you can if you really want to).
“#{row[18].round(0)}"

How to remove extra number in laravel

I am using Laravel 5.5 and using rating system, after average result i am getting
5.0000
I just want to show only
5
OR
5.0
How is this possible in laravel?
I am using this package for rating: https://github.com/AbdullahGhanem/rating
Thank you!
You can use
floor()
It will round a number down to the nearest integer. This will only work for positive values, which is an important assumption. For negative values, you'd want to use ceil(), but checking the sign of the input value would be cumbersome.
Hope this helps you.
Please refer this link
http://php.net/manual/en/function.floor.php
Use:
floor()
It's work for me! [use function php number_format()](https://www.w3schools.com/php/func_string_number_format.asp" PHP number_format() Function")

Mockaroo Formulas for random date range using Ruby

I am trying to create a data field using Mockaroo and they say they have Ruby support but I know nothing about Ruby so I am trying to find out how to do a field that will randomly choose between the 3 options.
now() or
now()+days(-1) or
now()+days(-2) or
now()+days(-3)
Idea 1
I was initially thinking something using random like now()+days(this.rand(-3))
Idea 2
I also thought of using or logic like now() or now()+days(-3) or etc...
This answer may end up being different than a typical ruby solution since Mockaroo has their own little API to use too... Appreciate any help that can be given.
Turns out I had to use the random function first and pass in min and max date parameters.
random(now()+days(2), now()+days(-3))

Resources