Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

103
Views
How do you add 0.1 to a setvalue?

I have a variable ekeys, which basically creates a ruler down a page and sets a depth (elevation) value down the ruler compared to the 0 value.

i.e. the ruler will show 1 metre depth. If surface elevation is set to 4.2 metres, then 1 metre down the corresponding elevation will be 4.2 metres minus 1 metre - which = 3.2 metres. For some reason it is 0.1 m out (i.e. showing 3.1 metres instead of 3.2 metres).

Is there an easy way to change this code: setValue(eKeys[k])

to add 0.1?

i.e. .setValue(eKeys[k]+0.1) <--- this does not work (it shows a value of 30.2 instead of 3.2).

var rKeys = Object.keys(mergeThisRows);
  var eKeys = Object.keys(mergeThisRowsE);
  for (k = 0; k < rKeys.length; k++) {
    shTemplate.getRange(mergeThisRows[rKeys[k]] + STARTT_ROW - 1, DEPTH_COL + 1, 2, 1).breakApart().merge().setValue(rKeys[k]).setFontColor("black").setFontSize(6).setVerticalAlignment("top").setHorizontalAlignment("right");
    shTemplate.getRange(mergeThisRows[rKeys[k]] + STARTT_ROW - 1, DEPTH_COL + 1, 2, 1).setBorder(true, null, null, null, null, null, '#000000', SpreadsheetApp.BorderStyle.SOLID);;
    if (eKeys[k] != undefined) {
      shTemplate.getRange(mergeThisRowsE[eKeys[k]] + STARTT_ROW - 1, ELEVATION_COL + 1, 2, 1).breakApart().merge().setValue(eKeys[k]).setNumberFormat("0.0").setFontColor("black").setFontSize(6).setVerticalAlignment("top").setHorizontalAlignment("right");
      shTemplate.getRange(mergeThisRowsE[eKeys[k]] + STARTT_ROW - 1, ELEVATION_COL + 1, 2, 1).setBorder(true, null, null, null, null, null, '#000000', SpreadsheetApp.BorderStyle.SOLID);
    }
  }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

I'd propose to use the unary + operator to convert the string into a number:

setValue(+eKeys[k] + 0.2)

Reference

  • Unary plus (+)
about 4 years ago · Juan Pablo Isaza Report

0

setValue(parseInt(eKeys[k])+0.2)
-> 3.2
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!